< Summary

Class:Tests.BuildModeHUDViews.SceneCatalogViewShould
Assembly:BuildModeHUDTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuildModeHUD/Tests/SceneCatalogViewShould.cs
Covered lines:48
Uncovered lines:0
Coverable lines:48
Total lines:150
Line coverage:100% (48 of 48)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetUp()0%110100%
TearDown()0%110100%
HideCatalogClickCorrectly()0%110100%
GoBackCorrectly()0%110100%
SetCatalogTitleCorrectly()0%110100%
CheckIfCatalogIsOpenCorrectly(...)0%110100%
CheckIfCatalogIsExpandedCorrectly(...)0%110100%
CloseCatalogCorrectly()0%330100%
SetActiveCorrectly()0%550100%
ShowBackButton(...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuildModeHUD/Tests/SceneCatalogViewShould.cs

#LineLine coverage
 1using NUnit.Framework;
 2using System.Collections;
 3using UnityEngine;
 4using UnityEngine.TestTools;
 5
 6namespace Tests.BuildModeHUDViews
 7{
 8    public class SceneCatalogViewShould
 9    {
 10        private SceneCatalogView sceneCatalogView;
 11
 12        [SetUp]
 2813        public void SetUp() { sceneCatalogView = SceneCatalogView.Create(); }
 14
 15        [TearDown]
 2816        public void TearDown() { Object.Destroy(sceneCatalogView.gameObject); }
 17
 18        [Test]
 19        public void HideCatalogClickCorrectly()
 20        {
 21            // Arrange
 122            bool hideCatalogClicked = false;
 223            sceneCatalogView.OnHideCatalogClicked += () => hideCatalogClicked = true;
 24
 25            // Act
 126            sceneCatalogView.OnHideCatalogClick();
 27
 28            // Assert
 129            Assert.IsTrue(hideCatalogClicked, "The hide catalog event has not been called!");
 130        }
 31
 32        [Test]
 33        public void GoBackCorrectly()
 34        {
 35            // Arrange
 136            bool backClicked = false;
 237            sceneCatalogView.OnSceneCatalogBack += () => backClicked = true;
 38
 39            // Act
 140            sceneCatalogView.Back();
 41
 42            // Assert
 143            Assert.IsTrue(backClicked, "The back event has not been called!");
 144        }
 45
 46        [Test]
 47        public void SetCatalogTitleCorrectly()
 48        {
 49            // Arrange
 150            string oldText = "Old text";
 151            string newText = "New text";
 152            sceneCatalogView.catalogTitleTxt.text = oldText;
 53
 54            // Act
 155            sceneCatalogView.SetCatalogTitle(newText);
 56
 57            // Assert
 158            Assert.AreEqual(newText, sceneCatalogView.catalogTitleTxt.text, "The catalog title does not match!");
 159        }
 60
 61        [Test]
 62        [TestCase(true)]
 63        [TestCase(false)]
 64        public void CheckIfCatalogIsOpenCorrectly(bool isOpen)
 65        {
 66            // Arrange
 267            sceneCatalogView.gameObject.SetActive(isOpen);
 68
 69            // Act
 270            bool isCatalogOpen = sceneCatalogView.IsCatalogOpen();
 71
 72            // Assert
 273            Assert.AreEqual(sceneCatalogView.gameObject.activeSelf, isCatalogOpen, "The catalog activation property does
 274        }
 75
 76        [Test]
 77        [TestCase(true)]
 78        [TestCase(false)]
 79        public void CheckIfCatalogIsExpandedCorrectly(bool isExpanded)
 80        {
 81            // Arrange
 282            sceneCatalogView.isCatalogExpanded = isExpanded;
 83
 84            // Act
 285            bool isCatalogExpanded = sceneCatalogView.IsCatalogExpanded();
 86
 87            // Assert
 288            Assert.AreEqual(sceneCatalogView.isCatalogExpanded, isCatalogExpanded, "The catalog expanded property does n
 289        }
 90
 91        [UnityTest]
 92        public IEnumerator CloseCatalogCorrectly()
 93        {
 94            // Arrange
 195            sceneCatalogView.gameObject.SetActive(true);
 96
 97            // Act
 198            sceneCatalogView.CloseCatalog();
 99
 100            // Assert
 1101            Assert.IsTrue(sceneCatalogView.isClosing, "The isClosing flag should be activated!");
 1102            yield return null;
 1103            Assert.IsFalse(sceneCatalogView.gameObject.activeSelf, "The catalog is not deactivated!");
 1104            Assert.IsFalse(sceneCatalogView.isClosing, "The isClosing flag should be deactivated!");
 1105        }
 106
 107        [UnityTest]
 108        [TestCase(true, true, ExpectedResult = null)]
 109        [TestCase(true, false, ExpectedResult = null)]
 110        [TestCase(false, true, ExpectedResult = null)]
 111        [TestCase(false, false, ExpectedResult = null)]
 112        public IEnumerator SetActiveCorrectly(bool isActive, bool isClosing)
 113        {
 114            // Arrange
 4115            sceneCatalogView.isClosing = isClosing;
 4116            sceneCatalogView.gameObject.SetActive(!isActive);
 117
 118            // Act
 4119            sceneCatalogView.SetActive(isActive);
 120
 121            // Assert
 4122            if (isActive && isClosing)
 123            {
 1124                Assert.AreEqual(!isActive, sceneCatalogView.gameObject.activeSelf);
 1125                sceneCatalogView.isClosing = false;
 1126                yield return null;
 127            }
 128
 4129            Assert.AreEqual(isActive, sceneCatalogView.gameObject.activeSelf, "The catalog has not been activated proper
 130
 4131            yield return null;
 4132            Assert.IsTrue(true);
 4133        }
 134
 135        [Test]
 136        [TestCase(true)]
 137        [TestCase(false)]
 138        public void ShowBackButton(bool isActive)
 139        {
 140            // Arrange
 2141            sceneCatalogView.backgBtn.gameObject.SetActive(!isActive);
 142
 143            // Act
 2144            sceneCatalogView.ShowBackButton(isActive);
 145
 146            // Assert
 2147            Assert.AreEqual(isActive, sceneCatalogView.backgBtn.gameObject.activeSelf, "The back button has not been act
 2148        }
 149    }
 150}