| | 1 | | using NUnit.Framework; |
| | 2 | | using SignupHUD; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | namespace Tests.SignupHUD |
| | 6 | | { |
| | 7 | | public class SignupHUDViewShould |
| | 8 | | { |
| | 9 | | private SignupHUDView hudView; |
| | 10 | |
|
| | 11 | | [SetUp] |
| 16 | 12 | | public void SetUp() { hudView = Object.Instantiate(Resources.Load<GameObject>("SignupHUD")).GetComponent<SignupH |
| | 13 | |
|
| | 14 | | [Test] |
| | 15 | | [TestCase(true)] |
| | 16 | | [TestCase(false)] |
| | 17 | | public void SetVisibilityProperly(bool visibility) |
| | 18 | | { |
| 2 | 19 | | hudView.SetVisibility(visibility); |
| 2 | 20 | | Assert.AreEqual(visibility, hudView.gameObject.activeSelf); |
| 2 | 21 | | } |
| | 22 | |
|
| | 23 | | [Test] |
| | 24 | | public void ShowNameScreenProperly() |
| | 25 | | { |
| 1 | 26 | | hudView.nameAndEmailPanel.gameObject.SetActive(false); |
| 1 | 27 | | hudView.termsOfServicePanel.gameObject.SetActive(true); |
| | 28 | |
|
| 1 | 29 | | hudView.ShowNameScreen(); |
| | 30 | |
|
| 1 | 31 | | Assert.AreEqual(true, hudView.nameAndEmailPanel.gameObject.activeSelf); |
| 1 | 32 | | Assert.AreEqual(false, hudView.termsOfServicePanel.gameObject.activeSelf); |
| 1 | 33 | | } |
| | 34 | |
|
| | 35 | | [Test] |
| | 36 | | public void ShowTermsOfServiceScreenProperly() |
| | 37 | | { |
| 1 | 38 | | hudView.nameAndEmailPanel.gameObject.SetActive(true); |
| 1 | 39 | | hudView.termsOfServicePanel.gameObject.SetActive(false); |
| | 40 | |
|
| 1 | 41 | | hudView.ShowTermsOfServiceScreen(); |
| | 42 | |
|
| 1 | 43 | | Assert.AreEqual(false, hudView.nameAndEmailPanel.gameObject.activeSelf); |
| 1 | 44 | | Assert.AreEqual(true, hudView.termsOfServicePanel.gameObject.activeSelf); |
| 1 | 45 | | } |
| | 46 | |
|
| | 47 | | [Test] |
| | 48 | | public void DisableNextButtonWithShortName() |
| | 49 | | { |
| 1 | 50 | | hudView.nameAndEmailNextButton.interactable = true; |
| 1 | 51 | | hudView.nameInputField.text = ""; |
| 1 | 52 | | hudView.emailInputField.text = ""; |
| | 53 | |
|
| 1 | 54 | | hudView.UpdateNameAndEmailNextButton(); |
| | 55 | |
|
| 1 | 56 | | Assert.IsFalse(hudView.nameAndEmailNextButton.interactable); |
| 1 | 57 | | } |
| | 58 | |
|
| | 59 | | [Test] |
| | 60 | | public void EnableNextButtonWithValidName() |
| | 61 | | { |
| 1 | 62 | | hudView.nameAndEmailNextButton.interactable = false; |
| 1 | 63 | | hudView.nameInputField.text = "ValidName"; |
| 1 | 64 | | hudView.emailInputField.text = ""; |
| | 65 | |
|
| 1 | 66 | | hudView.UpdateNameAndEmailNextButton(); |
| | 67 | |
|
| 1 | 68 | | Assert.IsTrue(hudView.nameAndEmailNextButton.interactable); |
| 1 | 69 | | } |
| | 70 | |
|
| | 71 | | [Test] |
| | 72 | | public void DisableNextButtonWithInvalidEmail() |
| | 73 | | { |
| 1 | 74 | | hudView.nameAndEmailNextButton.interactable = true; |
| 1 | 75 | | hudView.nameInputField.text = "ValidName"; |
| 1 | 76 | | hudView.emailInputField.text = "this_is_not_an_email"; |
| | 77 | |
|
| 1 | 78 | | hudView.UpdateNameAndEmailNextButton(); |
| | 79 | |
|
| 1 | 80 | | Assert.IsFalse(hudView.nameAndEmailNextButton.interactable); |
| 1 | 81 | | } |
| | 82 | |
|
| | 83 | | [Test] |
| | 84 | | public void EnableNextButtonWithValidEmail() |
| | 85 | | { |
| 1 | 86 | | hudView.nameAndEmailNextButton.interactable = true; |
| 1 | 87 | | hudView.nameInputField.text = "ValidName"; |
| 1 | 88 | | hudView.emailInputField.text = "myvalid@email.com"; |
| | 89 | |
|
| 1 | 90 | | hudView.UpdateNameAndEmailNextButton(); |
| | 91 | |
|
| 1 | 92 | | Assert.IsTrue(hudView.nameAndEmailNextButton.interactable); |
| 1 | 93 | | } |
| | 94 | |
|
| | 95 | | [TearDown] |
| 16 | 96 | | public void TearDown() { Object.Destroy(hudView.gameObject); } |
| | 97 | | } |
| | 98 | | } |