< Summary

Class:Tests.HUDControllerShould
Assembly:HUDTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/Tests/HUDTests.cs
Covered lines:23
Uncovered lines:0
Coverable lines:23
Total lines:70
Line coverage:100% (23 of 23)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetUp()0%330100%
TearDown()0%330100%
NotCreateHUDsInitially()0%330100%
CreateHudIfConfigurationIsActive()0%660100%

File(s)

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

#LineLine coverage
 1using System;
 2using NUnit.Framework;
 3using System.Collections;
 4using DCL;
 5using UnityEngine.TestTools;
 6
 7namespace Tests
 8{
 9    public class HUDControllerShould : IntegrationTestSuite_Legacy
 10    {
 211        protected override bool justSceneSetUp => true;
 12
 13        private IHUDController hudController = null;
 14
 15        protected override IEnumerator SetUp()
 16        {
 217            hudController = DCL.Environment.i.hud.controller;
 218            yield return base.SetUp();
 219            hudController.Cleanup();
 220        }
 21
 22        protected override IEnumerator TearDown()
 23        {
 224            hudController.Cleanup();
 225            yield return base.TearDown();
 226        }
 27
 28        [UnityTest]
 29        public IEnumerator NotCreateHUDsInitially()
 30        {
 31            // There must be a hud controller
 132            Assert.IsNotNull(hudController, "There must be a HUDController in the scene");
 33
 134            hudController.Cleanup();
 35            // HUD controllers are created
 6036            for (int i = 1; i < (int) HUDElementID.COUNT; i++)
 37            {
 2938                Assert.IsNull(hudController.GetHUDElement((HUDElementID) i));
 39            }
 40
 141            yield break;
 42        }
 43
 44        [UnityTest]
 45        public IEnumerator CreateHudIfConfigurationIsActive()
 46        {
 47            // There must be a hud controller
 148            Assert.IsNotNull(hudController, "There must be a HUDController in the scene");
 49
 150            HUDConfiguration config = new HUDConfiguration() { active = true, visible = true };
 51
 6052            for (int i = 1; i < (int) HUDElementID.COUNT; i++)
 53            {
 2954                hudController.ConfigureHUDElement((HUDElementID) i, config, null);
 55            }
 56
 157            yield return null;
 58
 59            // HUD controllers are created
 6060            for (int i = 1; i < (int) HUDElementID.COUNT; i++)
 61            {
 2962                HUDElementID elementID = (HUDElementID) i;
 2963                if (HUDController.IsHUDElementDeprecated(elementID))
 64                    continue;
 65
 2766                Assert.IsNotNull(hudController.GetHUDElement(elementID), $"Failed to create {elementID}");
 67            }
 168        }
 69    }
 70}