< Summary

Class:Tests.NavmapTests
Assembly:NavmapTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/NavMap/Tests/NavmapTests.cs
Covered lines:13
Uncovered lines:14
Coverable lines:27
Total lines:81
Line coverage:48.1% (13 of 27)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetUp()0%330100%
TearDown()0%330100%
Toggle()0%42600%
ReactToPlayerCoordsChange()0%110100%

File(s)

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

#LineLine coverage
 1using NUnit.Framework;
 2using System.Collections;
 3using System.Collections.Generic;
 4using UnityEngine;
 5using UnityEngine.TestTools;
 6
 7namespace Tests
 8{
 9    public class NavmapTests : IntegrationTestSuite_Legacy
 10    {
 11        private MinimapHUDController controller;
 12        DCL.NavmapView navmapView;
 113        protected override bool justSceneSetUp => true;
 14
 15        [UnitySetUp]
 16        protected override IEnumerator SetUp()
 17        {
 118            yield return base.SetUp();
 19
 120            controller = new MinimapHUDController();
 121            navmapView = Object.FindObjectOfType<DCL.NavmapView>();
 122        }
 23
 24        protected override IEnumerator TearDown()
 25        {
 126            controller.Dispose();
 127            yield return base.TearDown();
 128        }
 29
 30        [UnityTest]
 31        [Explicit]
 32        [Category("Explicit")]
 33        public IEnumerator Toggle()
 34        {
 035            InputAction_Trigger action = null;
 036            var inputController = GameObject.FindObjectOfType<InputController>();
 037            for (int i = 0; i < inputController.triggerTimeActions.Length; i++)
 38            {
 39                // Find the open nav map action used by the input controller
 040                if (inputController.triggerTimeActions[i].GetDCLAction() == DCLAction_Trigger.ToggleNavMap)
 41                {
 042                    action = inputController.triggerTimeActions[i];
 043                    break;
 44                }
 45            }
 46
 047            Assert.IsNotNull(action);
 48
 049            action.RaiseOnTriggered();
 50
 051            yield return null;
 52
 053            Assert.IsTrue(navmapView.scrollRect.gameObject.activeSelf);
 54
 055            action.RaiseOnTriggered();
 56
 057            yield return null;
 58
 059            Assert.IsFalse(navmapView.scrollRect.gameObject.activeSelf);
 060        }
 61
 62        [Test]
 63        public void ReactToPlayerCoordsChange()
 64        {
 65            const string sceneName = "SCENE_NAME";
 166            MinimapMetadata.GetMetadata()
 67                           .AddSceneInfo(
 68                               new MinimapMetadata.MinimapSceneInfo
 69                               {
 70                                   parcels = new List<Vector2Int>
 71                                   {
 72                                       new Vector2Int(-77, -77)
 73                                   },
 74                                   name = sceneName
 75                               });
 176            CommonScriptableObjects.playerCoords.Set(new Vector2Int(-77, -77));
 177            Assert.AreEqual(sceneName, navmapView.currentSceneNameText.text);
 178            Assert.AreEqual("-77,-77", navmapView.currentSceneCoordsText.text);
 179        }
 80    }
 81}