| | 1 | | using NUnit.Framework; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | namespace Tests.BuildModeHUDViews |
| | 5 | | { |
| | 6 | | public class BuildModeConfirmationModalViewShould |
| | 7 | | { |
| | 8 | | private BuildModeConfirmationModalView exitFromBiWModalView; |
| | 9 | |
|
| | 10 | | [SetUp] |
| 20 | 11 | | public void SetUp() { exitFromBiWModalView = BuildModeConfirmationModalView.Create(); } |
| | 12 | |
|
| | 13 | | [TearDown] |
| 20 | 14 | | public void TearDown() { Object.Destroy(exitFromBiWModalView.gameObject); } |
| | 15 | |
|
| | 16 | | [Test] |
| | 17 | | [TestCase(true)] |
| | 18 | | [TestCase(false)] |
| | 19 | | public void IsActiveCorrectly(bool isActive) |
| | 20 | | { |
| | 21 | | // Arrange |
| 2 | 22 | | exitFromBiWModalView.gameObject.SetActive(isActive); |
| | 23 | |
|
| | 24 | | // Assert |
| 2 | 25 | | Assert.AreEqual(isActive, exitFromBiWModalView.IsActive(), "Game object activate property does not match!"); |
| 2 | 26 | | } |
| | 27 | |
|
| | 28 | | [Test] |
| | 29 | | [TestCase(true)] |
| | 30 | | [TestCase(false)] |
| | 31 | | public void SetActiveCorrectly(bool isActive) |
| | 32 | | { |
| | 33 | | // Arrange |
| 2 | 34 | | exitFromBiWModalView.gameObject.SetActive(!isActive); |
| | 35 | |
|
| | 36 | | // Act |
| 2 | 37 | | exitFromBiWModalView.SetActive(isActive); |
| | 38 | |
|
| | 39 | | // Assert |
| 2 | 40 | | Assert.AreEqual(isActive, exitFromBiWModalView.gameObject.activeSelf, "Game object activate property does no |
| 2 | 41 | | } |
| | 42 | |
|
| | 43 | | [Test] |
| | 44 | | public void SetTitleCorrectly() |
| | 45 | | { |
| | 46 | | // Arrange |
| 1 | 47 | | string testText = "Test text"; |
| 1 | 48 | | exitFromBiWModalView.title.text = ""; |
| | 49 | |
|
| | 50 | | // Act |
| 1 | 51 | | exitFromBiWModalView.SetTitle(testText); |
| | 52 | |
|
| | 53 | | // Assert |
| 1 | 54 | | Assert.AreEqual(testText, exitFromBiWModalView.title.text, "Title text does not match!"); |
| 1 | 55 | | } |
| | 56 | |
|
| | 57 | | [Test] |
| | 58 | | public void SetSubTitleCorrectly() |
| | 59 | | { |
| | 60 | | // Arrange |
| 1 | 61 | | string testText = "Test text"; |
| 1 | 62 | | exitFromBiWModalView.subTitle.text = ""; |
| | 63 | |
|
| | 64 | | // Act |
| 1 | 65 | | exitFromBiWModalView.SetSubTitle(testText); |
| | 66 | |
|
| | 67 | | // Assert |
| 1 | 68 | | Assert.AreEqual(testText, exitFromBiWModalView.subTitle.text, "SubTitle text does not match!"); |
| 1 | 69 | | } |
| | 70 | |
|
| | 71 | | [Test] |
| | 72 | | public void SetCancelButtonTextCorrectly() |
| | 73 | | { |
| | 74 | | // Arrange |
| 1 | 75 | | string testText = "Test text"; |
| 1 | 76 | | exitFromBiWModalView.cancelButtonText.text = ""; |
| | 77 | |
|
| | 78 | | // Act |
| 1 | 79 | | exitFromBiWModalView.SetCancelButtonText(testText); |
| | 80 | |
|
| | 81 | | // Assert |
| 1 | 82 | | Assert.AreEqual(testText, exitFromBiWModalView.cancelButtonText.text, "cancelButtonText text does not match! |
| 1 | 83 | | } |
| | 84 | |
|
| | 85 | | [Test] |
| | 86 | | public void SetConfirmButtonTextCorrectly() |
| | 87 | | { |
| | 88 | | // Arrange |
| 1 | 89 | | string testText = "Test text"; |
| 1 | 90 | | exitFromBiWModalView.confirmButtonText.text = ""; |
| | 91 | |
|
| | 92 | | // Act |
| 1 | 93 | | exitFromBiWModalView.SetConfirmButtonText(testText); |
| | 94 | |
|
| | 95 | | // Assert |
| 1 | 96 | | Assert.AreEqual(testText, exitFromBiWModalView.confirmButtonText.text, "confirmButtonText text does not matc |
| 1 | 97 | | } |
| | 98 | |
|
| | 99 | | [Test] |
| | 100 | | public void CancelExitCorrectly() |
| | 101 | | { |
| | 102 | | // Arrange |
| 1 | 103 | | bool canceled = false; |
| 3 | 104 | | exitFromBiWModalView.OnCancelExit += () => { canceled = true; }; |
| | 105 | |
|
| | 106 | | // Act |
| 1 | 107 | | exitFromBiWModalView.CancelExit(); |
| | 108 | |
|
| | 109 | | // Assert |
| 1 | 110 | | Assert.IsTrue(canceled, "The canceled flag is false!"); |
| 1 | 111 | | } |
| | 112 | |
|
| | 113 | | [Test] |
| | 114 | | public void ConfirmExitCorrectly() |
| | 115 | | { |
| | 116 | | // Arrange |
| 1 | 117 | | bool confirmed = false; |
| 3 | 118 | | exitFromBiWModalView.OnConfirmExit += () => { confirmed = true; }; |
| | 119 | |
|
| | 120 | | // Act |
| 1 | 121 | | exitFromBiWModalView.ConfirmExit(); |
| | 122 | |
|
| | 123 | | // Assert |
| 1 | 124 | | Assert.IsTrue(confirmed, "The confirmed flag is false!"); |
| 1 | 125 | | } |
| | 126 | | } |
| | 127 | | } |