< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetUp()0%110100%
TearDown()0%110100%
OpenEntityListCorrectly()0%110100%
SetEntityListCorrectly()0%110100%
ClearListCorrectly()0%110100%
CloseListCorrectly()0%110100%
InvokeEntityActionCorrectly(...)0%550100%
EntityRenameCorrectly()0%110100%
SetCloseButtonsActionCorrectly()0%220100%

File(s)

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

#LineLine coverage
 1using NSubstitute;
 2using NUnit.Framework;
 3using System.Collections.Generic;
 4using UnityEngine;
 5using UnityEngine.Events;
 6
 7namespace Tests.BuildModeHUDControllers
 8{
 9    public class InspectorControllerShould
 10    {
 11        private InspectorController inspectorController;
 12
 13        [SetUp]
 14        public void SetUp()
 15        {
 1016            inspectorController = new InspectorController();
 1017            inspectorController.Initialize(Substitute.For<IInspectorView>());
 1018        }
 19
 20        [TearDown]
 2021        public void TearDown() { inspectorController.Dispose(); }
 22
 23        [Test]
 24        public void OpenEntityListCorrectly()
 25        {
 26            // Act
 127            inspectorController.OpenEntityList();
 28
 29            // Assert
 130            inspectorController.inspectorView.Received(1).SetActive(true);
 131        }
 32
 33        [Test]
 34        public void SetEntityListCorrectly()
 35        {
 36            // Arrange
 137            inspectorController.inspectorView.entityList = new GameObject("_EntityListView").AddComponent<EntityListView
 138            List<DCLBuilderInWorldEntity> testEntities = new List<DCLBuilderInWorldEntity>();
 39
 40            // Act
 141            inspectorController.SetEntityList(testEntities);
 42
 43            // Assert
 144            inspectorController.inspectorView.Received(1).SetEntitiesList(testEntities);
 145        }
 46
 47        [Test]
 48        public void ClearListCorrectly()
 49        {
 50            // Act
 151            inspectorController.ClearList();
 52
 53            // Assert
 154            inspectorController.inspectorView.Received(1).ClearEntitiesList();
 155        }
 56
 57        [Test]
 58        public void CloseListCorrectly()
 59        {
 60            // Act
 161            inspectorController.CloseList();
 62
 63            // Assert
 164            inspectorController.inspectorView.Received().SetActive(false);
 165        }
 66
 67        [Test]
 68        [TestCase(EntityAction.SELECT)]
 69        [TestCase(EntityAction.LOCK)]
 70        [TestCase(EntityAction.DELETE)]
 71        [TestCase(EntityAction.SHOW)]
 72        public void InvokeEntityActionCorrectly(EntityAction actionToInvoke)
 73        {
 74            // Arrange
 475            EntityAction testAction = actionToInvoke;
 476            DCLBuilderInWorldEntity testEntity = new GameObject("_DCLBuilderInWorldEntity").AddComponent<DCLBuilderInWor
 477            DCLBuilderInWorldEntity returnedEntity = null;
 78
 79            switch (actionToInvoke)
 80            {
 81                case EntityAction.SELECT:
 82
 383                    inspectorController.OnEntityClick += (entity) => { returnedEntity = entity; };
 184                    break;
 85                case EntityAction.LOCK:
 86
 387                    inspectorController.OnEntityLock += (entity) => { returnedEntity = entity; };
 188                    break;
 89                case EntityAction.DELETE:
 90
 391                    inspectorController.OnEntityDelete += (entity) => { returnedEntity = entity; };
 192                    break;
 93                case EntityAction.SHOW:
 394                    inspectorController.OnEntityChangeVisibility += (entity) => { returnedEntity = entity; };
 95                    break;
 96            }
 97
 98            // Act
 499            inspectorController.EntityActionInvoked(testAction, testEntity, null);
 100
 101            // Assert
 4102            Assert.AreEqual(testEntity, returnedEntity, "The entity does not match!");
 4103        }
 104
 105        [Test]
 106        public void EntityRenameCorrectly()
 107        {
 108            // Arrange
 1109            DCLBuilderInWorldEntity testEntity = new GameObject("_DCLBuilderInWorldEntity").AddComponent<DCLBuilderInWor
 1110            string testText = "Test text";
 1111            DCLBuilderInWorldEntity returnedEntity = null;
 1112            string returnedText = "";
 113
 1114            inspectorController.OnEntityRename += (entity, name) =>
 115            {
 1116                returnedEntity = entity;
 1117                returnedText = name;
 1118            };
 119
 120            // Act
 1121            inspectorController.EntityRename(testEntity, testText);
 122
 123            // Assert
 1124            Assert.AreEqual(testEntity, returnedEntity, "The entity does not match!");
 1125            Assert.AreEqual(testText, returnedText, "The text does not match!");
 1126        }
 127
 128        [Test]
 129        public void SetCloseButtonsActionCorrectly()
 130        {
 131            // Arrange
 1132            UnityAction testAction = () => { };
 133
 134            // Act
 1135            inspectorController.SetCloseButtonsAction(testAction);
 136
 137            // Assert
 1138            inspectorController.inspectorView.Received(1).SetCloseButtonsAction(testAction);
 1139        }
 140    }
 141}