| | 1 | | using NUnit.Framework; |
| | 2 | | using UnityEngine; |
| | 3 | | using UnityEngine.Events; |
| | 4 | |
|
| | 5 | | namespace Tests.BuildModeHUDViews |
| | 6 | | { |
| | 7 | | public class SceneLimitsViewShould |
| | 8 | | { |
| | 9 | | private SceneLimitsView sceneLimitsView; |
| | 10 | |
|
| | 11 | | [SetUp] |
| 18 | 12 | | public void SetUp() { sceneLimitsView = SceneLimitsView.Create(); } |
| | 13 | |
|
| | 14 | | [TearDown] |
| 18 | 15 | | public void TearDown() { Object.Destroy(sceneLimitsView.gameObject); } |
| | 16 | |
|
| | 17 | | [Test] |
| | 18 | | public void SetUpdateCallbackCorrectly() |
| | 19 | | { |
| | 20 | | // Arrange |
| 1 | 21 | | UnityAction testAction = () => { }; |
| | 22 | |
|
| | 23 | | // Act |
| 1 | 24 | | sceneLimitsView.SetUpdateCallback(testAction); |
| | 25 | |
|
| | 26 | | // Assert |
| 1 | 27 | | Assert.AreEqual(sceneLimitsView.updateInfoAction, testAction, "The update action does not match!"); |
| 1 | 28 | | } |
| | 29 | |
|
| | 30 | | [Test] |
| | 31 | | public void OnPointerExitCorrectly() |
| | 32 | | { |
| | 33 | | // Arrange |
| 1 | 34 | | bool isToggleDone = false; |
| 2 | 35 | | sceneLimitsView.OnToggleSceneLimitsInfo += () => isToggleDone = true; |
| | 36 | |
|
| | 37 | | // Act |
| 1 | 38 | | sceneLimitsView.ToggleSceneLimitsInfo(new DCLAction_Trigger()); |
| | 39 | |
|
| | 40 | | // Assert |
| 1 | 41 | | Assert.IsTrue(isToggleDone, "isToggleDone is false!"); |
| 1 | 42 | | } |
| | 43 | |
|
| | 44 | | [Test] |
| | 45 | | [TestCase(true)] |
| | 46 | | [TestCase(false)] |
| | 47 | | public void SetBodyActiveCorrectly(bool isActive) |
| | 48 | | { |
| | 49 | | // Arrange |
| 2 | 50 | | sceneLimitsView.sceneLimitsBodyGO.SetActive(!isActive); |
| | 51 | |
|
| | 52 | | // Act |
| 2 | 53 | | sceneLimitsView.SetBodyActive(isActive); |
| | 54 | |
|
| | 55 | | // Assert |
| 2 | 56 | | Assert.AreEqual(isActive, sceneLimitsView.sceneLimitsBodyGO.activeSelf, "The body active property does not m |
| 2 | 57 | | } |
| | 58 | |
|
| | 59 | | [Test] |
| | 60 | | public void SetDetailsToggleAsOpenCorrectly() |
| | 61 | | { |
| | 62 | | // Arrange |
| 1 | 63 | | sceneLimitsView.detailsToggleBtn.sprite = null; |
| | 64 | |
|
| | 65 | | // Act |
| 1 | 66 | | sceneLimitsView.SetDetailsToggleAsOpen(); |
| | 67 | |
|
| | 68 | | // Assert |
| 1 | 69 | | Assert.AreEqual(sceneLimitsView.openMenuSprite, sceneLimitsView.detailsToggleBtn.sprite, "The details toggle |
| 1 | 70 | | } |
| | 71 | |
|
| | 72 | | [Test] |
| | 73 | | public void SetDetailsToggleAsCloseCorrectly() |
| | 74 | | { |
| | 75 | | // Arrange |
| 1 | 76 | | sceneLimitsView.detailsToggleBtn.sprite = null; |
| | 77 | |
|
| | 78 | | // Act |
| 1 | 79 | | sceneLimitsView.SetDetailsToggleAsClose(); |
| | 80 | |
|
| | 81 | | // Assert |
| 1 | 82 | | Assert.AreEqual(sceneLimitsView.closeMenuSprite, sceneLimitsView.detailsToggleBtn.sprite, "The details toggl |
| 1 | 83 | | } |
| | 84 | |
|
| | 85 | | [Test] |
| | 86 | | public void SetTitleTextCorrectly() |
| | 87 | | { |
| | 88 | | // Arrange |
| 1 | 89 | | string newText = "Test text"; |
| 1 | 90 | | sceneLimitsView.titleTxt.text = ""; |
| | 91 | |
|
| | 92 | | // Act |
| 1 | 93 | | sceneLimitsView.SetTitleText(newText); |
| | 94 | |
|
| | 95 | | // Assert |
| 1 | 96 | | Assert.AreEqual(newText, sceneLimitsView.titleTxt.text, "The title text does not match!"); |
| 1 | 97 | | } |
| | 98 | |
|
| | 99 | | [Test] |
| | 100 | | public void SetLeftDescTextCorrectly() |
| | 101 | | { |
| | 102 | | // Arrange |
| 1 | 103 | | string newText = "Test text"; |
| 1 | 104 | | sceneLimitsView.leftDescTxt.text = ""; |
| | 105 | |
|
| | 106 | | // Act |
| 1 | 107 | | sceneLimitsView.SetLeftDescText(newText); |
| | 108 | |
|
| | 109 | | // Assert |
| 1 | 110 | | Assert.AreEqual(newText, sceneLimitsView.leftDescTxt.text, "The left text does not match!"); |
| 1 | 111 | | } |
| | 112 | |
|
| | 113 | | [Test] |
| | 114 | | public void SetRightDescTextCorrectly() |
| | 115 | | { |
| | 116 | | // Arrange |
| 1 | 117 | | string newText = "Test text"; |
| 1 | 118 | | sceneLimitsView.rightDescTxt.text = ""; |
| | 119 | |
|
| | 120 | | // Act |
| 1 | 121 | | sceneLimitsView.SetRightDescText(newText); |
| | 122 | |
|
| | 123 | | // Assert |
| 1 | 124 | | Assert.AreEqual(newText, sceneLimitsView.rightDescTxt.text, "The right text does not match!"); |
| 1 | 125 | | } |
| | 126 | | } |
| | 127 | | } |