| | 1 | | using NUnit.Framework; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | namespace Tests.BuildModeHUDViews |
| | 5 | | { |
| | 6 | | public class ExtraActionsViewShould |
| | 7 | | { |
| | 8 | | private ExtraActionsView extraActionsView; |
| | 9 | |
|
| | 10 | | [SetUp] |
| 18 | 11 | | public void SetUp() { extraActionsView = ExtraActionsView.Create(); } |
| | 12 | |
|
| | 13 | | [TearDown] |
| 18 | 14 | | public void TearDown() { Object.Destroy(extraActionsView.gameObject); } |
| | 15 | |
|
| | 16 | | [Test] |
| | 17 | | [TestCase(true)] |
| | 18 | | [TestCase(false)] |
| | 19 | | public void SetActiveCorrectly(bool isActive) |
| | 20 | | { |
| | 21 | | // Arrange |
| 2 | 22 | | extraActionsView.gameObject.SetActive(!isActive); |
| | 23 | |
|
| | 24 | | // Act |
| 2 | 25 | | extraActionsView.SetActive(isActive); |
| | 26 | |
|
| | 27 | | // Assert |
| 2 | 28 | | Assert.AreEqual(isActive, extraActionsView.gameObject.activeSelf, "The active property does not match!"); |
| 2 | 29 | | } |
| | 30 | |
|
| | 31 | | [Test] |
| | 32 | | public void ClickOnControlsCorrectly() |
| | 33 | | { |
| | 34 | | // Arrange |
| 1 | 35 | | bool isClicked = false; |
| 2 | 36 | | extraActionsView.OnControlsClicked += () => isClicked = true; |
| | 37 | |
|
| | 38 | | // Act |
| 1 | 39 | | extraActionsView.OnControlsClick(new DCLAction_Trigger()); |
| | 40 | |
|
| | 41 | | // Assert |
| 1 | 42 | | Assert.IsTrue(isClicked, "isClicked is false!"); |
| 1 | 43 | | } |
| | 44 | |
|
| | 45 | | [Test] |
| | 46 | | public void ClickOnHideUICorrectly() |
| | 47 | | { |
| | 48 | | // Arrange |
| 1 | 49 | | bool isClicked = false; |
| 2 | 50 | | extraActionsView.OnHideUIClicked += () => isClicked = true; |
| | 51 | |
|
| | 52 | | // Act |
| 1 | 53 | | extraActionsView.OnHideUIClick(new DCLAction_Trigger()); |
| | 54 | |
|
| | 55 | | // Assert |
| 1 | 56 | | Assert.IsTrue(isClicked, "isClicked is false!"); |
| 1 | 57 | | } |
| | 58 | |
|
| | 59 | | [Test] |
| | 60 | | public void ClickOnTutorialCorrectly() |
| | 61 | | { |
| | 62 | | // Arrange |
| 1 | 63 | | bool isClicked = false; |
| 2 | 64 | | extraActionsView.OnTutorialClicked += () => isClicked = true; |
| | 65 | |
|
| | 66 | | // Act |
| 1 | 67 | | extraActionsView.OnTutorialClick(); |
| | 68 | |
|
| | 69 | | // Assert |
| 1 | 70 | | Assert.IsTrue(isClicked, "isClicked is false!"); |
| 1 | 71 | | } |
| | 72 | |
|
| | 73 | | [Test] |
| | 74 | | public void ClickOnResetCorrectly() |
| | 75 | | { |
| | 76 | | // Arrange |
| 1 | 77 | | bool isClicked = false; |
| 2 | 78 | | extraActionsView.OnResetClicked += () => isClicked = true; |
| | 79 | |
|
| | 80 | | // Act |
| 1 | 81 | | extraActionsView.OnResetClick(new DCLAction_Trigger()); |
| | 82 | |
|
| | 83 | | // Assert |
| 1 | 84 | | Assert.IsTrue(isClicked, "isClicked is false!"); |
| 1 | 85 | | } |
| | 86 | |
|
| | 87 | | [Test] |
| | 88 | | public void ClickOnResetCameraCorrectly() |
| | 89 | | { |
| | 90 | | // Arrange |
| 1 | 91 | | bool isClicked = false; |
| 2 | 92 | | extraActionsView.OnResetCameraClicked += () => isClicked = true; |
| | 93 | |
|
| | 94 | | // Act |
| 1 | 95 | | extraActionsView.OnResetCameraClick(new DCLAction_Trigger()); |
| | 96 | |
|
| | 97 | | // Assert |
| 1 | 98 | | Assert.IsTrue(isClicked, "isClicked is false!"); |
| 1 | 99 | | } |
| | 100 | |
|
| | 101 | | [Test] |
| | 102 | | [TestCase(true)] |
| | 103 | | [TestCase(false)] |
| | 104 | | public void SetResetButtonInteractableCorrectly(bool isInteractable) |
| | 105 | | { |
| | 106 | | // Arrange |
| 2 | 107 | | extraActionsView.resetBtn.interactable = !isInteractable; |
| | 108 | |
|
| | 109 | | // Act |
| 2 | 110 | | extraActionsView.SetResetButtonInteractable(isInteractable); |
| | 111 | |
|
| | 112 | | // Assert |
| 2 | 113 | | Assert.AreEqual(isInteractable, extraActionsView.resetBtn.interactable, "The interactable property does not |
| 2 | 114 | | } |
| | 115 | | } |
| | 116 | | } |