< Summary

Class:InputController_Tests.InputAction_Trigger_Should
Assembly:InputControllerTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/InputController/Tests/InputController_Tests.cs
Covered lines:21
Uncovered lines:0
Coverable lines:21
Total lines:164
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%
Have_WasTriggeredThisFrame_Off_ByDefault()0%110100%
Have_WasTriggeredThisFrame_On_AfterRaisingInTheSameFrame()0%110100%
Have_WasTriggeredThisFrame_Off_AfterRaisingInDifferentFrame()0%330100%
CallTriggeredEvent()0%110100%
ReturnDCLActionProperly()0%110100%
ReturnIsTriggerBlockedProperly()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]
 1213        public void SetUp() { action = ScriptableObject.CreateInstance<InputAction_Trigger>(); }
 14
 15        [Test]
 216        public void Have_WasTriggeredThisFrame_Off_ByDefault() { Assert.IsFalse(action.WasTriggeredThisFrame()); }
 17
 18        [Test]
 19        public void Have_WasTriggeredThisFrame_On_AfterRaisingInTheSameFrame()
 20        {
 121            action.RaiseOnTriggered();
 122            Assert.True(action.WasTriggeredThisFrame());
 123        }
 24
 25        [UnityTest]
 26        public IEnumerator Have_WasTriggeredThisFrame_Off_AfterRaisingInDifferentFrame()
 27        {
 128            action.RaiseOnTriggered();
 129            yield return null;
 130            Assert.False(action.WasTriggeredThisFrame());
 131        }
 32
 33        [Test]
 34        public void CallTriggeredEvent()
 35        {
 136            bool called = false;
 237            action.OnTriggered += x => called = true;
 38
 139            action.RaiseOnTriggered();
 40
 141            Assert.IsTrue(called);
 142        }
 43
 44        [Test]
 45        public void ReturnDCLActionProperly()
 46        {
 147            action.dclAction = DCLAction_Trigger.CameraChange;
 48
 149            Assert.AreEqual(DCLAction_Trigger.CameraChange, action.GetDCLAction());
 150        }
 51
 52        [Test]
 53        public void ReturnIsTriggerBlockedProperly()
 54        {
 155            action.blockTrigger = new BooleanVariable();
 156            action.blockTrigger.Set(true);
 57
 158            Assert.AreEqual(true, action.isTriggerBlocked.Get());
 159        }
 60    }
 61
 62    public class InputAction_Hold_Should
 63    {
 64        private InputAction_Hold action;
 65
 66        [SetUp]
 67        public void SetUp() { action = ScriptableObject.CreateInstance<InputAction_Hold>(); }
 68
 69        [Test]
 70        public void BeOffByDefault() { Assert.IsFalse(action.isOn); }
 71
 72        [Test]
 73        public void CallStartedEvent()
 74        {
 75            bool called = false;
 76            action.OnStarted += x => called = true;
 77
 78            action.RaiseOnStarted();
 79
 80            Assert.IsTrue(called);
 81        }
 82
 83        [Test]
 84        public void CallFinishedEvent()
 85        {
 86            bool called = false;
 87            action.OnFinished += x => called = true;
 88
 89            action.RaiseOnFinished();
 90
 91            Assert.IsTrue(called);
 92        }
 93
 94        [Test]
 95        public void BeOnAfterStartedIsRaised()
 96        {
 97            action.RaiseOnStarted();
 98            Assert.IsTrue(action.isOn);
 99        }
 100
 101        [Test]
 102        public void BeOffAfterFinishedIsRaised()
 103        {
 104            action.RaiseOnStarted();
 105            action.RaiseOnFinished();
 106            Assert.IsFalse(action.isOn);
 107        }
 108
 109        [Test]
 110        public void ReturnDCLActionProperly()
 111        {
 112            action.dclAction = DCLAction_Hold.Sprint;
 113
 114            Assert.AreEqual(DCLAction_Hold.Sprint, action.GetDCLAction());
 115        }
 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}