< Summary

Class:Tests.SceneCardViewShould
Assembly:BuilderProjectsPanelTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuilderProjectsPanel/Tests/SceneCardViewShould.cs
Covered lines:30
Uncovered lines:0
Coverable lines:30
Total lines:115
Line coverage:100% (30 of 30)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetUp()0%110100%
TearDown()0%110100%
DisplayCorrectlyWhenSceneIsDeployed()0%110100%
DisplayCorrectlyWhenSceneIsNotDeployed()0%110100%
DisplayCorrectlyWhenSceneIsNotEditable()0%110100%
DisplayCorrectlyWhenSceneIsEditable()0%110100%

File(s)

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

#LineLine coverage
 1using NUnit.Framework;
 2using UnityEditor;
 3using UnityEngine;
 4
 5namespace Tests
 6{
 7    public class SceneCardViewShould
 8    {
 9        private SceneCardView cardView;
 10
 11        [SetUp]
 12        public void SetUp()
 13        {
 14            const string prefabAssetPath =
 15                "Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuilderProjectsPanel/Prefabs/SceneCardView.prefab";
 416            var prefab = AssetDatabase.LoadAssetAtPath<SceneCardView>(prefabAssetPath);
 417            cardView = UnityEngine.Object.Instantiate(prefab);
 418        }
 19
 20        [TearDown]
 821        public void TearDown() { UnityEngine.Object.Destroy(cardView.gameObject); }
 22
 23        [Test]
 24        public void DisplayCorrectlyWhenSceneIsDeployed()
 25        {
 126            ((ISceneCardView)cardView).Setup(new SceneData()
 27            {
 28                id = "",
 29                isDeployed = true,
 30                name = "test",
 31                coords = Vector2Int.zero,
 32                size = Vector2Int.zero,
 33                isOwner = true,
 34                isEditable = true
 35            });
 36
 37            //should show both jump-in and editor buttons
 138            Assert.IsTrue(cardView.jumpInButton.gameObject.activeSelf, "JumpIn button should be active");
 139            Assert.IsTrue(cardView.editorButton.gameObject.activeSelf, "Editor button should be active");
 40
 41            //should show coords instead of size
 142            Assert.IsTrue(cardView.coordsContainer.activeSelf, "Coords should be displayed");
 143            Assert.IsFalse(cardView.sizeContainer.activeSelf, "Size should not be displayed");
 44
 45            //should show role
 146            Assert.IsTrue(cardView.roleOwnerGO.activeSelf, "Owner role tag should be displayed");
 147            Assert.IsFalse(cardView.roleOperatorGO.activeSelf, "Operator role tag should not be displayed");
 148            Assert.IsFalse(cardView.roleContributorGO.activeSelf, "Contributor role tag should not be displayed");
 149        }
 50
 51        [Test]
 52        public void DisplayCorrectlyWhenSceneIsNotDeployed()
 53        {
 154            ((ISceneCardView)cardView).Setup(new SceneData()
 55            {
 56                id = "",
 57                isDeployed = false,
 58                name = "test",
 59                coords = Vector2Int.zero,
 60                size = Vector2Int.zero,
 61                isContributor = true,
 62                isEditable = true
 63            });
 64
 65            //should show only editor button, no jump-in
 166            Assert.IsFalse(cardView.jumpInButton.gameObject.activeSelf, "JumpIn button should not be active");
 167            Assert.IsTrue(cardView.editorButton.gameObject.activeSelf, "Editor button should be active");
 68
 69            //should show size instead of coords
 170            Assert.IsFalse(cardView.coordsContainer.activeSelf, "Coords should not be displayed");
 171            Assert.IsTrue(cardView.sizeContainer.activeSelf, "Size should be displayed");
 72
 73            //should show role
 174            Assert.IsTrue(cardView.roleContributorGO.activeSelf, "Contributor role tag should be displayed");
 175            Assert.IsFalse(cardView.roleOperatorGO.activeSelf, "Operator role tag should not be displayed");
 176            Assert.IsFalse(cardView.roleOwnerGO.activeSelf, "Owner role tag should not be displayed");
 177        }
 78
 79        [Test]
 80        public void DisplayCorrectlyWhenSceneIsNotEditable()
 81        {
 182            ((ISceneCardView)cardView).Setup(new SceneData()
 83            {
 84                id = "",
 85                isDeployed = false,
 86                name = "test",
 87                coords = Vector2Int.zero,
 88                size = Vector2Int.zero,
 89                isContributor = true,
 90                isEditable = false
 91            });
 92
 193            Assert.IsFalse(cardView.editorButton.gameObject.activeSelf, "Editor button should not be active");
 194            Assert.IsTrue(cardView.editorLockedGO.activeSelf, "Editor locked indicator should be active");
 195        }
 96
 97        [Test]
 98        public void DisplayCorrectlyWhenSceneIsEditable()
 99        {
 1100            ((ISceneCardView)cardView).Setup(new SceneData()
 101            {
 102                id = "",
 103                isDeployed = false,
 104                name = "test",
 105                coords = Vector2Int.zero,
 106                size = Vector2Int.zero,
 107                isContributor = true,
 108                isEditable = true
 109            });
 110
 1111            Assert.IsTrue(cardView.editorButton.gameObject.activeSelf, "Editor button should be active");
 1112            Assert.IsFalse(cardView.editorLockedGO.activeSelf, "Editor locked indicator should not be active");
 1113        }
 114    }
 115}