| | 1 | | using NUnit.Framework; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | namespace Tests.BuildModeHUDViews |
| | 5 | | { |
| | 6 | | public class ShortcutsViewShould |
| | 7 | | { |
| | 8 | | private ShortcutsView shortcutsView; |
| | 9 | |
|
| | 10 | | [SetUp] |
| 6 | 11 | | public void SetUp() { shortcutsView = ShortcutsView.Create(); } |
| | 12 | |
|
| | 13 | | [TearDown] |
| 6 | 14 | | public void TearDown() { Object.Destroy(shortcutsView.gameObject); } |
| | 15 | |
|
| | 16 | | [Test] |
| | 17 | | [TestCase(true)] |
| | 18 | | [TestCase(false)] |
| | 19 | | public void SetActiveCorrectly(bool isActive) |
| | 20 | | { |
| | 21 | | // Arrange |
| 2 | 22 | | shortcutsView.gameObject.SetActive(!isActive); |
| | 23 | |
|
| | 24 | | // Act |
| 2 | 25 | | shortcutsView.SetActive(isActive); |
| | 26 | |
|
| | 27 | | // Assert |
| 2 | 28 | | Assert.AreEqual(isActive, shortcutsView.gameObject.activeSelf, "The active property does not match!"); |
| 2 | 29 | | } |
| | 30 | |
|
| | 31 | | [Test] |
| | 32 | | public void ClickOnCloseCorrectly() |
| | 33 | | { |
| | 34 | | // Arrange |
| 1 | 35 | | bool isClosed = false; |
| 2 | 36 | | shortcutsView.OnCloseButtonClick += () => isClosed = true; |
| | 37 | |
|
| | 38 | | // Act |
| 1 | 39 | | shortcutsView.OnCloseClick(); |
| | 40 | |
|
| | 41 | | // Assert |
| 1 | 42 | | Assert.IsTrue(isClosed, "isClosed is false!"); |
| 1 | 43 | | } |
| | 44 | | } |
| | 45 | | } |