| | 1 | | using System.Collections; |
| | 2 | | using NUnit.Framework; |
| | 3 | | using UnityEngine.TestTools; |
| | 4 | |
|
| | 5 | | namespace ExpressionsHUD_Test |
| | 6 | | { |
| | 7 | | public class ExpressionsHUDControllerShould : IntegrationTestSuite_Legacy |
| | 8 | | { |
| | 9 | | private ExpressionsHUDController controller; |
| | 10 | |
|
| | 11 | | [UnitySetUp] |
| | 12 | | protected override IEnumerator SetUp() |
| | 13 | | { |
| 2 | 14 | | yield return base.SetUp(); |
| 2 | 15 | | controller = new ExpressionsHUDController(); |
| 2 | 16 | | } |
| | 17 | |
|
| | 18 | | [UnityTearDown] |
| | 19 | | protected override IEnumerator TearDown() |
| | 20 | | { |
| 2 | 21 | | controller.Dispose(); |
| 2 | 22 | | yield return base.TearDown(); |
| 2 | 23 | | } |
| | 24 | |
|
| | 25 | | [Test] |
| | 26 | | public void CreateView() |
| | 27 | | { |
| 1 | 28 | | Assert.NotNull(controller.view); |
| 1 | 29 | | Assert.NotNull(controller.view.gameObject); |
| 1 | 30 | | } |
| | 31 | |
|
| | 32 | | [Test] |
| | 33 | | public void UpdateOwnUserProfileWhenExpressionIsCalled() |
| | 34 | | { |
| 1 | 35 | | controller.ExpressionCalled("wave"); |
| | 36 | |
|
| 1 | 37 | | Assert.AreEqual("wave", UserProfile.GetOwnUserProfile().avatar.expressionTriggerId); |
| 1 | 38 | | } |
| | 39 | | } |
| | 40 | |
|
| | 41 | | public class ExpressionsHUDViewShould : IntegrationTestSuite_Legacy |
| | 42 | | { |
| | 43 | | private ExpressionsHUDController controller; |
| | 44 | | private ExpressionsHUDView view; |
| | 45 | |
|
| | 46 | | [UnitySetUp] |
| | 47 | | protected override IEnumerator SetUp() |
| | 48 | | { |
| | 49 | | yield return base.SetUp(); |
| | 50 | | controller = new ExpressionsHUDController(); |
| | 51 | | view = controller.view; |
| | 52 | | } |
| | 53 | |
|
| | 54 | | protected override IEnumerator TearDown() |
| | 55 | | { |
| | 56 | | controller.Dispose(); |
| | 57 | | yield return base.TearDown(); |
| | 58 | | } |
| | 59 | |
|
| | 60 | | [Test] |
| | 61 | | public void BeInitializedProperly() |
| | 62 | | { |
| | 63 | | view.content.gameObject.SetActive(true); |
| | 64 | | view.Initialize(null); |
| | 65 | | Assert.IsFalse(view.content.gameObject.activeSelf); |
| | 66 | | } |
| | 67 | |
|
| | 68 | | [Test] |
| | 69 | | public void RegisterButtonsCallbackProperly() |
| | 70 | | { |
| | 71 | | string expressionCalled = null; |
| | 72 | | ExpressionsHUDView.ExpressionClicked callback = (x) => expressionCalled = x; |
| | 73 | | view.Initialize(callback); |
| | 74 | |
|
| | 75 | | view.buttonToExpressionMap[0].button.OnPointerDown(null); |
| | 76 | |
|
| | 77 | | Assert.AreEqual(view.buttonToExpressionMap[0].expressionId, expressionCalled); |
| | 78 | | } |
| | 79 | |
|
| | 80 | | [Test] |
| | 81 | | public void ToggleContentProperly() |
| | 82 | | { |
| | 83 | | var currentActive = view.content.gameObject.activeSelf; |
| | 84 | | view.ToggleContent(); |
| | 85 | | Assert.AreNotEqual(currentActive, view.content.gameObject.activeSelf); |
| | 86 | |
|
| | 87 | | currentActive = view.content.gameObject.activeSelf; |
| | 88 | | view.ToggleContent(); |
| | 89 | | Assert.AreNotEqual(currentActive, view.content.gameObject.activeSelf); |
| | 90 | |
|
| | 91 | | currentActive = view.content.gameObject.activeSelf; |
| | 92 | | view.ToggleContent(); |
| | 93 | | Assert.AreNotEqual(currentActive, view.content.gameObject.activeSelf); |
| | 94 | | } |
| | 95 | |
|
| | 96 | | [Test] |
| | 97 | | public void ReactToOpenExpressionsInputAction() |
| | 98 | | { |
| | 99 | | var inputAction = view.openExpressionsAction; |
| | 100 | |
|
| | 101 | | var currentActive = view.content.gameObject.activeSelf; |
| | 102 | | inputAction.RaiseOnTriggered(); |
| | 103 | | Assert.AreNotEqual(currentActive, view.content.gameObject.activeSelf); |
| | 104 | |
|
| | 105 | | currentActive = view.content.gameObject.activeSelf; |
| | 106 | | inputAction.RaiseOnTriggered(); |
| | 107 | | Assert.AreNotEqual(currentActive, view.content.gameObject.activeSelf); |
| | 108 | | } |
| | 109 | | } |
| | 110 | | } |