| | 1 | | using NUnit.Framework; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | namespace Tests.BuildModeHUDViews |
| | 5 | | { |
| | 6 | | public class PublishPopupViewShould |
| | 7 | | { |
| | 8 | | private PublishPopupView publishPopupView; |
| | 9 | |
|
| | 10 | | [SetUp] |
| 6 | 11 | | public void SetUp() { publishPopupView = PublishPopupView.Create(); } |
| | 12 | |
|
| | 13 | | [TearDown] |
| 6 | 14 | | public void TearDown() { Object.Destroy(publishPopupView.gameObject); } |
| | 15 | |
|
| | 16 | | [Test] |
| | 17 | | public void PublishStartCorrectly() |
| | 18 | | { |
| | 19 | | // Arrange |
| 1 | 20 | | publishPopupView.gameObject.SetActive(false); |
| 1 | 21 | | publishPopupView.loadingBar.SetActive(false); |
| 1 | 22 | | publishPopupView.resultText.gameObject.SetActive(true); |
| 1 | 23 | | publishPopupView.closeButton.gameObject.SetActive(true); |
| 1 | 24 | | publishPopupView.errorDetailsText.gameObject.SetActive(true); |
| 1 | 25 | | publishPopupView.titleText.text = ""; |
| | 26 | |
|
| | 27 | | // Act |
| 1 | 28 | | publishPopupView.PublishStart(); |
| | 29 | |
|
| | 30 | | // Assert |
| 1 | 31 | | Assert.IsTrue(publishPopupView.gameObject.activeSelf, "game object activate property is false!"); |
| 1 | 32 | | Assert.IsTrue(publishPopupView.loadingBar.gameObject.activeSelf, "loadingBar activate property is false!"); |
| 1 | 33 | | Assert.IsFalse(publishPopupView.resultText.gameObject.activeInHierarchy, "resultText activate property is tr |
| 1 | 34 | | Assert.IsFalse(publishPopupView.closeButton.gameObject.activeInHierarchy, "closeButton activate property is |
| 1 | 35 | | Assert.IsFalse(publishPopupView.errorDetailsText.gameObject.activeInHierarchy, "errorDetailsText activate pr |
| 1 | 36 | | Assert.AreEqual(PublishPopupView.TITLE_INITIAL_MESSAGE, publishPopupView.titleText.text, "titleText dies not |
| 1 | 37 | | } |
| | 38 | |
|
| | 39 | | [Test] |
| | 40 | | [TestCase(true)] |
| | 41 | | [TestCase(false)] |
| | 42 | | public void PublishEndCorrectly(bool isOk) |
| | 43 | | { |
| | 44 | | // Arrange |
| 2 | 45 | | string testErrorMessage = "Test text"; |
| 2 | 46 | | publishPopupView.loadingBar.SetActive(true); |
| 2 | 47 | | publishPopupView.titleText.text = ""; |
| 2 | 48 | | publishPopupView.resultText.text = ""; |
| 2 | 49 | | publishPopupView.resultText.gameObject.SetActive(false); |
| 2 | 50 | | publishPopupView.errorDetailsText.text = "test"; |
| 2 | 51 | | publishPopupView.errorDetailsText.gameObject.SetActive(isOk); |
| 2 | 52 | | publishPopupView.closeButton.gameObject.SetActive(false); |
| | 53 | |
|
| | 54 | | // Act |
| 2 | 55 | | publishPopupView.PublishEnd(isOk, testErrorMessage); |
| | 56 | |
|
| | 57 | | // Assert |
| 2 | 58 | | if (isOk) |
| | 59 | | { |
| 1 | 60 | | Assert.AreEqual(PublishPopupView.SUCCESS_TITLE_MESSAGE, publishPopupView.titleText.text, "titleText dies |
| 1 | 61 | | Assert.AreEqual(PublishPopupView.SUCCESS_MESSAGE, publishPopupView.resultText.text, "resultText dies not |
| 1 | 62 | | Assert.AreEqual("", publishPopupView.errorDetailsText.text, "errorDetailsText dies not march!"); |
| 1 | 63 | | Assert.IsFalse(publishPopupView.errorDetailsText.gameObject.activeInHierarchy, "errorDetailsText activat |
| 1 | 64 | | } |
| | 65 | | else |
| | 66 | | { |
| 1 | 67 | | Assert.AreEqual(PublishPopupView.FAIL_TITLE_MESSAGE, publishPopupView.titleText.text, "titleText dies no |
| 1 | 68 | | Assert.AreEqual(PublishPopupView.FAIL_MESSAGE, publishPopupView.resultText.text, "resultText dies not ma |
| 1 | 69 | | Assert.AreEqual(testErrorMessage, publishPopupView.errorDetailsText.text, "errorDetailsText dies not mar |
| 1 | 70 | | Assert.IsTrue(publishPopupView.errorDetailsText.gameObject.activeInHierarchy, "errorDetailsText activate |
| | 71 | | } |
| 2 | 72 | | Assert.IsFalse(publishPopupView.loadingBar.gameObject.activeSelf, "loadingBar activate property is false!"); |
| 2 | 73 | | Assert.IsTrue(publishPopupView.resultText.gameObject.activeInHierarchy, "resultText activate property is fal |
| 2 | 74 | | Assert.IsTrue(publishPopupView.closeButton.gameObject.activeInHierarchy, "closeButton activate property is f |
| 2 | 75 | | } |
| | 76 | | } |
| | 77 | | } |