< Summary

Class:Tests.NotificationHudTests
Assembly:NotificationHudTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/NotificationHUD/Tests/NotificationHudTests.cs
Covered lines:47
Uncovered lines:0
Coverable lines:47
Total lines:124
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%330100%
TearDown()0%330100%
NotificationHud_Creation()0%110100%
NotificationHud_ModelDefaulted()0%110100%
NotificationHud_ShowNotification()0%330100%
NotificationHud_ShowSeveralNotifications()0%330100%
NotificationHud_ShowTimedNotification()0%440100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/NotificationHUD/Tests/NotificationHudTests.cs

#LineLine coverage
 1using NUnit.Framework;
 2using System.Collections;
 3using UnityEngine;
 4using UnityEngine.TestTools;
 5
 6namespace Tests
 7{
 8    public class NotificationHudTests : IntegrationTestSuite_Legacy
 9    {
 10        private NotificationHUDController controller;
 11
 12        protected override IEnumerator SetUp()
 13        {
 514            yield return base.SetUp();
 515            controller = new NotificationHUDController();
 516            sceneInitialized = false;
 517        }
 18
 19        protected override IEnumerator TearDown()
 20        {
 521            controller.Dispose();
 522            yield return base.TearDown();
 523        }
 24
 25        [Test]
 26        public void NotificationHud_Creation()
 27        {
 128            var views = GameObject.FindObjectsOfType<NotificationHUDView>();
 29
 130            Assert.AreEqual(1, views.Length);
 31
 132            var view = views[0];
 133            Assert.NotNull(view);
 134            Assert.AreEqual(view, controller.view);
 135        }
 36
 37        [Test]
 38        public void NotificationHud_ModelDefaulted()
 39        {
 140            Assert.IsNotNull(controller.model);
 141            Assert.IsNotNull(controller.model.notifications);
 142            Assert.AreEqual(controller.model.notifications.Count, 0);
 143        }
 44
 45        [UnityTest]
 46        public IEnumerator NotificationHud_ShowNotification()
 47        {
 148            Notification.Model model = new Notification.Model()
 49            {
 50                type = NotificationFactory.Type.GENERIC,
 51                message = "text",
 52                timer = -1,
 53                scene = ""
 54            };
 55
 156            controller.ShowNotification(model);
 57
 158            yield return null;
 59
 160            Notification[] notifications = GameObject.FindObjectsOfType<Notification>();
 161            Assert.AreEqual(notifications.Length, 1);
 62
 163            Notification n = notifications[0];
 164            Assert.AreEqual(n.model.type, model.type);
 165            Assert.AreEqual(n.model.message, model.message);
 166            Assert.AreEqual(n.model.timer, model.timer);
 167            Assert.AreEqual(n.model.scene, model.scene);
 168        }
 69
 70        [UnityTest]
 71        public IEnumerator NotificationHud_ShowSeveralNotifications()
 72        {
 173            Notification.Model model = new Notification.Model()
 74            {
 75                type = NotificationFactory.Type.GENERIC,
 76                message = "text",
 77                timer = -1,
 78                scene = ""
 79            };
 80
 181            controller.ShowNotification(model);
 82
 183            Notification.Model model2 = new Notification.Model()
 84            {
 85                type = NotificationFactory.Type.SCRIPTING_ERROR,
 86                message = "text",
 87                timer = -1,
 88                scene = ""
 89            };
 90
 191            controller.ShowNotification(model2);
 92
 193            yield return null;
 94
 195            Notification[] notifications = GameObject.FindObjectsOfType<Notification>();
 196            Assert.AreEqual(2, notifications.Length);
 197        }
 98
 99        [UnityTest]
 100        public IEnumerator NotificationHud_ShowTimedNotification()
 101        {
 1102            Notification.Model model = new Notification.Model()
 103            {
 104                type = NotificationFactory.Type.GENERIC,
 105                message = "text",
 106                timer = 0.25f,
 107                scene = ""
 108            };
 109
 1110            controller.ShowNotification(model);
 1111            yield return null;
 112
 1113            Notification[] notifications = GameObject.FindObjectsOfType<Notification>();
 1114            Assert.AreEqual(notifications.Length, 1);
 1115            Assert.AreEqual(controller.model.notifications.Count, 1);
 116
 108117            yield return new DCL.WaitUntil(() => notifications.Length == 0, 0.5f);
 118
 1119            notifications = GameObject.FindObjectsOfType<Notification>();
 1120            Assert.AreEqual(notifications.Length, 0);
 1121            Assert.AreEqual(controller.model.notifications.Count, 0);
 1122        }
 123    }
 124}