< Summary

Class:Tests.QuestsNotificationsHUD.QuestsNotificationsHUDViewShould
Assembly:QuestsTrackerHUDTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/QuestsTrackerHUD/Tests/QuestsNotificationsHUDViewShould.cs
Covered lines:21
Uncovered lines:0
Coverable lines:21
Total lines:53
Line coverage:100% (21 of 21)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetUp()0%110100%
ReactToQuestCompleted()0%110100%
ProcessNotificationsQueue()0%660100%
TearDown()0%110100%

File(s)

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

#LineLine coverage
 1using DCL;
 2using DCL.Huds.QuestsTracker;
 3using NUnit.Framework;
 4using System.Collections;
 5using UnityEngine;
 6using UnityEngine.TestTools;
 7
 8namespace Tests.QuestsNotificationsHUD
 9{
 10    public class QuestsNotificationsHUDViewShould
 11    {
 12        private QuestsNotificationsController controller;
 13
 14        [SetUp]
 15        public void SetUp()
 16        {
 17            // Even though we set duration to 0, we have to wait a frame anyway for the yields to be performed.
 218            QuestsNotificationsController.DEFAULT_NOTIFICATION_DURATION = 0f;
 219            QuestsNotificationsController.NOTIFICATIONS_SEPARATION = 0f;
 220            controller = Object.Instantiate(Resources.Load<GameObject>("QuestsTrackerHUD")).GetComponentInChildren<Quest
 221        }
 22
 23        [Test]
 24        public void ReactToQuestCompleted()
 25        {
 126            controller.ShowQuestCompleted(new QuestModel { name = "theName" });
 127            Assert.AreEqual(1, controller.transform.childCount);
 128            var notificationComponent = controller.transform.GetChild(0).GetComponent<QuestNotification_QuestCompleted>(
 129            Assert.NotNull(notificationComponent);
 130            Assert.AreEqual("theName", notificationComponent.questName.text);
 131        }
 32
 33        [UnityTest]
 34        public IEnumerator ProcessNotificationsQueue()
 35        {
 136            controller.ShowQuestCompleted(new QuestModel());
 137            controller.ShowQuestCompleted(new QuestModel());
 38
 139            Assert.AreEqual(2, controller.notificationsQueue.Count);
 40
 141            yield return null; // Wait for notification to go away.
 142            yield return null; // Wait for notification time separation.
 143            Assert.AreEqual(1, controller.notificationsQueue.Count);
 44
 145            yield return null; // Wait for notification to go away.
 146            yield return null; // Wait for notification time separation.
 147            Assert.AreEqual(0, controller.notificationsQueue.Count);
 148        }
 49
 50        [TearDown]
 451        public void TearDown() { Object.Destroy(controller.gameObject); }
 52    }
 53}