< Summary

Class:Tests.BuildModeHUDViews.FirstPersonModeViewShould
Assembly:BuildModeHUDTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuildModeHUD/Tests/FirstPersonModeViewShould.cs
Covered lines:24
Uncovered lines:0
Coverable lines:24
Total lines:67
Line coverage:100% (24 of 24)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetUp()0%110100%
TearDown()0%110100%
OnPointerClickCorrectly()0%110100%
OnPointerEnterCorrectly()0%110100%
OnPointerExitCorrectly()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuildModeHUD/Tests/FirstPersonModeViewShould.cs

#LineLine coverage
 1using NUnit.Framework;
 2using UnityEngine;
 3using UnityEngine.EventSystems;
 4
 5namespace Tests.BuildModeHUDViews
 6{
 7    public class FirstPersonModeViewShould
 8    {
 9        private FirstPersonModeView firstPersonModeView;
 10
 11        [SetUp]
 612        public void SetUp() { firstPersonModeView = FirstPersonModeView.Create(); }
 13
 14        [TearDown]
 615        public void TearDown() { Object.Destroy(firstPersonModeView.gameObject); }
 16
 17        [Test]
 18        public void OnPointerClickCorrectly()
 19        {
 20            // Arrange
 121            bool isClicked = false;
 222            firstPersonModeView.OnFirstPersonModeClick += () => isClicked = true;
 23
 24            // Act
 125            firstPersonModeView.OnPointerClick();
 26
 27            // Assert
 128            Assert.IsTrue(isClicked, "isClicked is false!");
 129        }
 30
 31        [Test]
 32        public void OnPointerEnterCorrectly()
 33        {
 34            // Arrange
 135            PointerEventData sentEventData = new PointerEventData(null);
 136            firstPersonModeView.tooltipText = "Test text";
 137            PointerEventData returnedEventData = null;
 138            string returnedTooltipText = "";
 139            firstPersonModeView.OnShowTooltip += (data, text) =>
 40            {
 141                returnedEventData = (PointerEventData)data;
 142                returnedTooltipText = text;
 143            };
 44
 45            // Act
 146            firstPersonModeView.OnPointerEnter(sentEventData);
 47
 48            // Assert
 149            Assert.AreEqual(sentEventData, returnedEventData, "The event data does not match!");
 150            Assert.AreEqual(firstPersonModeView.tooltipText, returnedTooltipText, "The tooltip text does not match!");
 151        }
 52
 53        [Test]
 54        public void OnPointerExitCorrectly()
 55        {
 56            // Arrange
 157            bool isHidden = false;
 258            firstPersonModeView.OnHideTooltip += () => isHidden = true;
 59
 60            // Act
 161            firstPersonModeView.OnPointerExit();
 62
 63            // Assert
 164            Assert.IsTrue(isHidden, "isHidden is false!");
 165        }
 66    }
 67}