< Summary

Class:Tests.NavmapToastViewShould
Assembly:NavmapTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/NavMap/Tests/NavmapToastViewShould.cs
Covered lines:30
Uncovered lines:11
Coverable lines:41
Total lines:110
Line coverage:73.1% (30 of 41)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetUp()0%550100%
TearDown()0%330100%
CloseWhenCloseButtonIsClicked()0%110100%
BePopulatedCorrectlyWithNullOrEmptyElements()0%2100%
BePopulatedCorrectly()0%110100%

File(s)

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

#LineLine coverage
 1using DCL;
 2using NUnit.Framework;
 3using System.Collections;
 4using System.Collections.Generic;
 5using UnityEngine;
 6using UnityEngine.TestTools;
 7
 8namespace Tests
 9{
 10    public class NavmapToastViewShould : IntegrationTestSuite_Legacy
 11    {
 12        NavmapToastView navmapToastView;
 13        private NavmapView navmapView;
 214        protected override bool justSceneSetUp => true;
 15
 16        [UnitySetUp]
 17        protected override IEnumerator SetUp()
 18        {
 219            yield return base.SetUp();
 220            yield return null;
 21
 222            navmapView = Object.FindObjectOfType<NavmapView>();
 223            navmapToastView = navmapView.toastView;
 24
 225            if (!NavmapView.isOpen)
 126                navmapView.ToggleNavMap();
 227        }
 28
 29        protected override IEnumerator TearDown()
 30        {
 231            navmapView.Initialize();
 232            yield return base.TearDown();
 233        }
 34
 35        [Test]
 36        public void CloseWhenCloseButtonIsClicked()
 37        {
 138            var sceneInfo = new MinimapMetadata.MinimapSceneInfo()
 39            {
 40                name = "foo",
 41                owner = null,
 42                description = "",
 43                isPOI = false,
 44                parcels = new List<Vector2Int>() { new Vector2Int(10, 10), new Vector2Int(10, 11), new Vector2Int(10, 12
 45            };
 46
 147            MinimapMetadata.GetMetadata().Clear();
 148            MinimapMetadata.GetMetadata().AddSceneInfo(sceneInfo);
 49
 150            navmapToastView.Populate(new Vector2Int(10, 11), sceneInfo);
 151            Assert.IsTrue(navmapToastView.gameObject.activeSelf);
 152            navmapToastView.OnCloseClick();
 153            Assert.IsFalse(navmapToastView.gameObject.activeSelf);
 154        }
 55
 56        [Test]
 57        [Explicit("This fails only on run all for some reason")]
 58        [Category("Explicit")]
 59        public void BePopulatedCorrectlyWithNullOrEmptyElements()
 60        {
 061            var sceneInfo = new MinimapMetadata.MinimapSceneInfo()
 62            {
 63                name = "foo",
 64                owner = null,
 65                description = "",
 66                isPOI = false,
 67                parcels = new List<Vector2Int>() { new Vector2Int(10, 10), new Vector2Int(10, 11), new Vector2Int(10, 12
 68            };
 69
 070            MinimapMetadata.GetMetadata().Clear();
 071            MinimapMetadata.GetMetadata().AddSceneInfo(sceneInfo);
 72
 073            navmapToastView.Populate(new Vector2Int(10, 11), sceneInfo);
 074            Assert.IsTrue(navmapToastView.gameObject.activeSelf);
 75
 076            Assert.IsTrue(navmapToastView.sceneLocationText.transform.parent.gameObject.activeInHierarchy);
 077            Assert.AreEqual("10, 11", navmapToastView.sceneLocationText.text);
 78
 079            Assert.IsTrue(navmapToastView.sceneTitleText.transform.parent.gameObject.activeInHierarchy);
 080            Assert.IsFalse(navmapToastView.sceneOwnerText.transform.parent.gameObject.activeInHierarchy);
 081            Assert.IsFalse(navmapToastView.scenePreviewContainer.gameObject.activeInHierarchy);
 082        }
 83
 84        [Test]
 85        public void BePopulatedCorrectly()
 86        {
 187            var sceneInfo = new MinimapMetadata.MinimapSceneInfo()
 88            {
 89                name = "foo",
 90                owner = "bar",
 91                description = "foobar",
 92                isPOI = false,
 93                parcels = new List<Vector2Int>() { new Vector2Int(10, 10), new Vector2Int(10, 11), new Vector2Int(10, 12
 94            };
 95
 196            MinimapMetadata.GetMetadata().Clear();
 197            MinimapMetadata.GetMetadata().AddSceneInfo(sceneInfo);
 98
 199            navmapToastView.Populate(new Vector2Int(10, 10), sceneInfo);
 1100            Assert.IsTrue(navmapToastView.gameObject.activeSelf);
 101
 1102            Assert.AreEqual(sceneInfo.name, navmapToastView.sceneTitleText.text);
 1103            Assert.AreEqual($"Created by: {sceneInfo.owner}", navmapToastView.sceneOwnerText.text);
 1104            Assert.AreEqual("10, 10", navmapToastView.sceneLocationText.text);
 105
 1106            Assert.IsTrue(navmapToastView.sceneTitleText.gameObject.activeInHierarchy);
 1107            Assert.IsTrue(navmapToastView.sceneOwnerText.gameObject.activeInHierarchy);
 1108        }
 109    }
 110}