-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
abbdbff
commit 6b0e18c
Showing
13 changed files
with
182 additions
and
37 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
9 changes: 7 additions & 2 deletions
9
Mobile Game Store/Assets/Scripts/Events/Data/RefreshCurrencyAmountEventData.cs
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.
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,59 @@ | ||
using JGM.GameStore.Events.Data; | ||
using JGM.GameStore.HUD; | ||
using Moq; | ||
using NUnit.Framework; | ||
using System.Collections; | ||
using TMPro; | ||
using UnityEngine; | ||
using UnityEngine.TestTools; | ||
|
||
namespace JGM.GameStoreTests.HUD | ||
{ | ||
public class CurrencyHUDTest | ||
{ | ||
private CurrencyHUD _currencyHUD; | ||
private Mock<ICurrencyEventData> _gameEventDataMock; | ||
private const float _testCurrencyAmount = 200f; | ||
|
||
[UnitySetUp] | ||
public IEnumerator SetUp() | ||
{ | ||
var dummyGO = new GameObject("Dummy"); | ||
_currencyHUD = dummyGO.AddComponent<CurrencyHUD>(); | ||
_gameEventDataMock = new Mock<ICurrencyEventData>(); | ||
_gameEventDataMock.SetupGet(x => x.Amount).Returns(_testCurrencyAmount); | ||
yield return new WaitForEndOfFrame(); | ||
} | ||
|
||
[UnityTest] | ||
public IEnumerator OnComponentAwake_NoTMPIsAttached_LogsError() | ||
{ | ||
GameObject.Destroy(_currencyHUD.GetComponent<TextMeshProUGUI>()); | ||
yield return new WaitForEndOfFrame(); | ||
LogAssert.Expect(LogType.Error, "Can't remove TextMeshProUGUI (Script) because CurrencyHUD (Script) depends on it"); | ||
} | ||
|
||
[Test] | ||
public void OnComponentAwake_TMPIsAttached_AmountIsZero() | ||
{ | ||
float currencyAmount = float.Parse(_currencyHUD.GetComponent<TextMeshProUGUI>().text); | ||
Assert.AreEqual(0f, currencyAmount); | ||
} | ||
|
||
[Test] | ||
public void OnRefreshCurrencyAmount_DataPassedIsNull_AmountIsZero() | ||
{ | ||
_currencyHUD.RefreshCurrencyAmount(new Mock<ICurrencyEventData>().Object); | ||
float currencyAmount = float.Parse(_currencyHUD.GetComponent<TextMeshProUGUI>().text); | ||
Assert.AreEqual(0f, currencyAmount); | ||
} | ||
|
||
[Test] | ||
public void OnRefreshCurrencyAmount_DataPassedIsValid_ReturnsExpectedAmount() | ||
{ | ||
_currencyHUD.RefreshCurrencyAmount(_gameEventDataMock.Object); | ||
float currencyAmount = float.Parse(_currencyHUD.GetComponent<TextMeshProUGUI>().text); | ||
Assert.AreEqual(_testCurrencyAmount, currencyAmount); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Mobile Game Store/Assets/Tests/HUD/CurrencyHUDTest.cs.meta
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,24 @@ | ||
{ | ||
"name": "JGM.GameStoreTests", | ||
"rootNamespace": "", | ||
"references": [ | ||
"GUID:27619889b8ba8c24980f49ee34dbb44a", | ||
"GUID:0acc523941302664db1f4e527237feb3", | ||
"GUID:6374b22523226c546bd57944e41676e8", | ||
"GUID:6055be8ebefd69e48b49212b09b47b2f" | ||
], | ||
"includePlatforms": [], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": true, | ||
"precompiledReferences": [ | ||
"nunit.framework.dll", | ||
"Moq.dll" | ||
], | ||
"autoReferenced": false, | ||
"defineConstraints": [ | ||
"UNITY_INCLUDE_TESTS" | ||
], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
7 changes: 7 additions & 0 deletions
7
Mobile Game Store/Assets/Tests/JGM.GameStoreTests.asmdef.meta
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
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