-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from philipcass/tests
Tests
- Loading branch information
Showing
8 changed files
with
188 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using System; | ||
using NUnit.Framework; | ||
using uClicker; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace Tests | ||
{ | ||
public class Tests | ||
{ | ||
private ClickerManager _testManager; | ||
private Currency _testCurrency; | ||
private Clickable _testClickable; | ||
|
||
[SetUp] | ||
public void CreateObjects() | ||
{ | ||
_testManager = ScriptableObject.CreateInstance<ClickerManager>(); | ||
_testCurrency = ScriptableObject.CreateInstance<Currency>(); | ||
_testClickable = ScriptableObject.CreateInstance<Clickable>(); | ||
_testManager.SaveSettings.SaveName = "TEST_SAVE"; | ||
_testManager.SaveSettings.SavePath = Application.dataPath; | ||
} | ||
|
||
[TearDown] | ||
public void TearDown() | ||
{ | ||
_testManager.ClearProgress(); | ||
} | ||
|
||
[TestCase(3, ExpectedResult = 3)] | ||
public int TestClicking(int clickCount) | ||
{ | ||
_testClickable.Currency = _testCurrency; | ||
_testClickable.Amount = 1; | ||
ArrayUtility.Add(ref _testManager.Config.Currencies, _testCurrency); | ||
_testManager.OnEnable(); | ||
|
||
Assert.AreEqual(0, _testManager.State.CurrencyCurrentTotals[_testCurrency]); | ||
for (int i = 0; i < clickCount; i++) | ||
{ | ||
_testManager.Click(_testClickable); | ||
} | ||
|
||
return (int) _testManager.State.CurrencyCurrentTotals[_testCurrency]; | ||
} | ||
|
||
[Test] | ||
public void TestGenerators() | ||
{ | ||
_testClickable.Currency = _testCurrency; | ||
_testClickable.Amount = 1; | ||
ArrayUtility.Add(ref _testManager.Config.Currencies, _testCurrency); | ||
|
||
var building = ScriptableObject.CreateInstance<Building>(); | ||
building.YieldAmount = new CurrencyTuple() | ||
{ | ||
Amount = 5, | ||
Currency = _testCurrency | ||
}; | ||
_testManager.State.EarnedBuildings[building] = 1; | ||
_testManager.OnEnable(); | ||
_testManager.Tick(); | ||
Assert.AreEqual(5, _testManager.State.CurrencyCurrentTotals[_testCurrency]); | ||
} | ||
|
||
[TestCase(ManagerSaveSettings.SaveTypeEnum.SaveToPlayerPrefs)] | ||
[TestCase(ManagerSaveSettings.SaveTypeEnum.SaveToFile)] | ||
public void TestSave(ManagerSaveSettings.SaveTypeEnum saveType) | ||
{ | ||
_testClickable.Currency = _testCurrency; | ||
_testClickable.Amount = 1; | ||
ArrayUtility.Add(ref _testManager.Config.Currencies, _testCurrency); | ||
|
||
_testManager.SaveSettings.SaveType = saveType; | ||
Assert.Throws<ArgumentException>(() => { _testManager.LoadProgress(); }); | ||
_testManager.SaveProgress(); | ||
_testManager.LoadProgress(); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "uClicker.Tests", | ||
"references": [ | ||
"UnityEngine.TestRunner", | ||
"UnityEditor.TestRunner", | ||
"uClicker.Runtime" | ||
], | ||
"includePlatforms": [ | ||
"Editor" | ||
], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": true, | ||
"precompiledReferences": [ | ||
"nunit.framework.dll" | ||
], | ||
"autoReferenced": false, | ||
"defineConstraints": [ | ||
"UNITY_INCLUDE_TESTS" | ||
], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.