< Summary

Class:ExpressionsHUD_Test.ExpressionsHUDControllerShould
Assembly:ExpressionsHUDTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/ExpressionsHUD/Test/ExpressionsHUDControllerShould.cs
Covered lines:12
Uncovered lines:0
Coverable lines:12
Total lines:110
Line coverage:100% (12 of 12)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetUp()0%330100%
TearDown()0%330100%
CreateView()0%110100%
UpdateOwnUserProfileWhenExpressionIsCalled()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/ExpressionsHUD/Test/ExpressionsHUDControllerShould.cs

#LineLine coverage
 1using System.Collections;
 2using NUnit.Framework;
 3using UnityEngine.TestTools;
 4
 5namespace ExpressionsHUD_Test
 6{
 7    public class ExpressionsHUDControllerShould : IntegrationTestSuite_Legacy
 8    {
 9        private ExpressionsHUDController controller;
 10
 11        [UnitySetUp]
 12        protected override IEnumerator SetUp()
 13        {
 214            yield return base.SetUp();
 215            controller = new ExpressionsHUDController();
 216        }
 17
 18        [UnityTearDown]
 19        protected override IEnumerator TearDown()
 20        {
 221            controller.Dispose();
 222            yield return base.TearDown();
 223        }
 24
 25        [Test]
 26        public void CreateView()
 27        {
 128            Assert.NotNull(controller.view);
 129            Assert.NotNull(controller.view.gameObject);
 130        }
 31
 32        [Test]
 33        public void UpdateOwnUserProfileWhenExpressionIsCalled()
 34        {
 135            controller.ExpressionCalled("wave");
 36
 137            Assert.AreEqual("wave", UserProfile.GetOwnUserProfile().avatar.expressionTriggerId);
 138        }
 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}