< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetUp()0%330100%
TearDown()0%330100%
BeInitializedProperly()0%110100%
RegisterButtonsCallbackProperly()0%110100%
ToggleContentProperly()0%110100%
ReactToOpenExpressionsInputAction()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        {
 14            yield return base.SetUp();
 15            controller = new ExpressionsHUDController();
 16        }
 17
 18        [UnityTearDown]
 19        protected override IEnumerator TearDown()
 20        {
 21            controller.Dispose();
 22            yield return base.TearDown();
 23        }
 24
 25        [Test]
 26        public void CreateView()
 27        {
 28            Assert.NotNull(controller.view);
 29            Assert.NotNull(controller.view.gameObject);
 30        }
 31
 32        [Test]
 33        public void UpdateOwnUserProfileWhenExpressionIsCalled()
 34        {
 35            controller.ExpressionCalled("wave");
 36
 37            Assert.AreEqual("wave", UserProfile.GetOwnUserProfile().avatar.expressionTriggerId);
 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        {
 449            yield return base.SetUp();
 450            controller = new ExpressionsHUDController();
 451            view = controller.view;
 452        }
 53
 54        protected override IEnumerator TearDown()
 55        {
 456            controller.Dispose();
 457            yield return base.TearDown();
 458        }
 59
 60        [Test]
 61        public void BeInitializedProperly()
 62        {
 163            view.content.gameObject.SetActive(true);
 164            view.Initialize(null);
 165            Assert.IsFalse(view.content.gameObject.activeSelf);
 166        }
 67
 68        [Test]
 69        public void RegisterButtonsCallbackProperly()
 70        {
 171            string expressionCalled = null;
 272            ExpressionsHUDView.ExpressionClicked callback = (x) => expressionCalled = x;
 173            view.Initialize(callback);
 74
 175            view.buttonToExpressionMap[0].button.OnPointerDown(null);
 76
 177            Assert.AreEqual(view.buttonToExpressionMap[0].expressionId, expressionCalled);
 178        }
 79
 80        [Test]
 81        public void ToggleContentProperly()
 82        {
 183            var currentActive = view.content.gameObject.activeSelf;
 184            view.ToggleContent();
 185            Assert.AreNotEqual(currentActive, view.content.gameObject.activeSelf);
 86
 187            currentActive = view.content.gameObject.activeSelf;
 188            view.ToggleContent();
 189            Assert.AreNotEqual(currentActive, view.content.gameObject.activeSelf);
 90
 191            currentActive = view.content.gameObject.activeSelf;
 192            view.ToggleContent();
 193            Assert.AreNotEqual(currentActive, view.content.gameObject.activeSelf);
 194        }
 95
 96        [Test]
 97        public void ReactToOpenExpressionsInputAction()
 98        {
 199            var inputAction = view.openExpressionsAction;
 100
 1101            var currentActive = view.content.gameObject.activeSelf;
 1102            inputAction.RaiseOnTriggered();
 1103            Assert.AreNotEqual(currentActive, view.content.gameObject.activeSelf);
 104
 1105            currentActive = view.content.gameObject.activeSelf;
 1106            inputAction.RaiseOnTriggered();
 1107            Assert.AreNotEqual(currentActive, view.content.gameObject.activeSelf);
 1108        }
 109    }
 110}