< Summary

Class:InputController_Tests.InputAction_Hold_Should
Assembly:InputControllerTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/InputController/Tests/InputController_Tests.cs
Covered lines:22
Uncovered lines:0
Coverable lines:22
Total lines:164
Line coverage:100% (22 of 22)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetUp()0%110100%
BeOffByDefault()0%110100%
CallStartedEvent()0%110100%
CallFinishedEvent()0%110100%
BeOnAfterStartedIsRaised()0%110100%
BeOffAfterFinishedIsRaised()0%110100%
ReturnDCLActionProperly()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/InputController/Tests/InputController_Tests.cs

#LineLine coverage
 1using System.Collections;
 2using NUnit.Framework;
 3using UnityEngine;
 4using UnityEngine.TestTools;
 5
 6namespace InputController_Tests
 7{
 8    public class InputAction_Trigger_Should
 9    {
 10        private InputAction_Trigger action;
 11
 12        [SetUp]
 13        public void SetUp() { action = ScriptableObject.CreateInstance<InputAction_Trigger>(); }
 14
 15        [Test]
 16        public void Have_WasTriggeredThisFrame_Off_ByDefault() { Assert.IsFalse(action.WasTriggeredThisFrame()); }
 17
 18        [Test]
 19        public void Have_WasTriggeredThisFrame_On_AfterRaisingInTheSameFrame()
 20        {
 21            action.RaiseOnTriggered();
 22            Assert.True(action.WasTriggeredThisFrame());
 23        }
 24
 25        [UnityTest]
 26        public IEnumerator Have_WasTriggeredThisFrame_Off_AfterRaisingInDifferentFrame()
 27        {
 28            action.RaiseOnTriggered();
 29            yield return null;
 30            Assert.False(action.WasTriggeredThisFrame());
 31        }
 32
 33        [Test]
 34        public void CallTriggeredEvent()
 35        {
 36            bool called = false;
 37            action.OnTriggered += x => called = true;
 38
 39            action.RaiseOnTriggered();
 40
 41            Assert.IsTrue(called);
 42        }
 43
 44        [Test]
 45        public void ReturnDCLActionProperly()
 46        {
 47            action.dclAction = DCLAction_Trigger.CameraChange;
 48
 49            Assert.AreEqual(DCLAction_Trigger.CameraChange, action.GetDCLAction());
 50        }
 51
 52        [Test]
 53        public void ReturnIsTriggerBlockedProperly()
 54        {
 55            action.blockTrigger = new BooleanVariable();
 56            action.blockTrigger.Set(true);
 57
 58            Assert.AreEqual(true, action.isTriggerBlocked.Get());
 59        }
 60    }
 61
 62    public class InputAction_Hold_Should
 63    {
 64        private InputAction_Hold action;
 65
 66        [SetUp]
 1267        public void SetUp() { action = ScriptableObject.CreateInstance<InputAction_Hold>(); }
 68
 69        [Test]
 270        public void BeOffByDefault() { Assert.IsFalse(action.isOn); }
 71
 72        [Test]
 73        public void CallStartedEvent()
 74        {
 175            bool called = false;
 276            action.OnStarted += x => called = true;
 77
 178            action.RaiseOnStarted();
 79
 180            Assert.IsTrue(called);
 181        }
 82
 83        [Test]
 84        public void CallFinishedEvent()
 85        {
 186            bool called = false;
 287            action.OnFinished += x => called = true;
 88
 189            action.RaiseOnFinished();
 90
 191            Assert.IsTrue(called);
 192        }
 93
 94        [Test]
 95        public void BeOnAfterStartedIsRaised()
 96        {
 197            action.RaiseOnStarted();
 198            Assert.IsTrue(action.isOn);
 199        }
 100
 101        [Test]
 102        public void BeOffAfterFinishedIsRaised()
 103        {
 1104            action.RaiseOnStarted();
 1105            action.RaiseOnFinished();
 1106            Assert.IsFalse(action.isOn);
 1107        }
 108
 109        [Test]
 110        public void ReturnDCLActionProperly()
 111        {
 1112            action.dclAction = DCLAction_Hold.Sprint;
 113
 1114            Assert.AreEqual(DCLAction_Hold.Sprint, action.GetDCLAction());
 1115        }
 116    }
 117
 118    public class InputAction_Measurable_Should
 119    {
 120        private InputAction_Measurable action;
 121
 122        [SetUp]
 123        public void SetUp() { action = ScriptableObject.CreateInstance<InputAction_Measurable>(); }
 124
 125        [Test]
 126        public void Return_0_AsDefaultValue() { Assert.AreEqual(0, action.GetValue()); }
 127
 128        [Test]
 129        [TestCase(1)]
 130        [TestCase(2)]
 131        [TestCase(-1)]
 132        [TestCase(0.5f)]
 133        public void UpdateValueProperly(float newValue)
 134        {
 135            action.RaiseOnValueChanged(newValue);
 136            Assert.AreEqual(newValue, action.GetValue());
 137        }
 138
 139        [Test]
 140        public void CallOnValueChangedEvent()
 141        {
 142            var called = false;
 143            var calledValue = 18f;
 144
 145            action.OnValueChanged += (x, value) =>
 146            {
 147                called = true;
 148                calledValue = value;
 149            };
 150            action.RaiseOnValueChanged(18f);
 151
 152            Assert.IsTrue(called);
 153            Assert.AreEqual(18f, calledValue);
 154        }
 155
 156        [Test]
 157        public void ReturnDCLActionProperly()
 158        {
 159            action.dclAction = DCLAction_Measurable.CameraXAxis;
 160
 161            Assert.AreEqual(DCLAction_Measurable.CameraXAxis, action.GetDCLAction());
 162        }
 163    }
 164}