| | 1 | | using NUnit.Framework; |
| | 2 | | using System.Collections; |
| | 3 | | using TMPro; |
| | 4 | | using UnityEngine; |
| | 5 | | using UnityEngine.TestTools; |
| | 6 | |
|
| | 7 | | namespace Tests |
| | 8 | | { |
| | 9 | | public class MinimapHUDTests : IntegrationTestSuite_Legacy |
| | 10 | | { |
| | 11 | | private MinimapHUDController controller; |
| | 12 | |
|
| | 13 | | [UnitySetUp] |
| | 14 | | protected override IEnumerator SetUp() |
| | 15 | | { |
| 7 | 16 | | yield return base.SetUp(); |
| 7 | 17 | | controller = new MinimapHUDController(); |
| 7 | 18 | | } |
| | 19 | |
|
| | 20 | | protected override IEnumerator TearDown() |
| | 21 | | { |
| 7 | 22 | | controller.Dispose(); |
| 7 | 23 | | yield return base.TearDown(); |
| 7 | 24 | | } |
| | 25 | |
|
| | 26 | | [Test] |
| | 27 | | public void MinimapHUD_Creation() |
| | 28 | | { |
| 1 | 29 | | var containerName = MinimapHUDView.VIEW_OBJECT_NAME; |
| 1 | 30 | | var viewContainer = GameObject.Find(containerName); |
| | 31 | |
|
| 1 | 32 | | Assert.NotNull(viewContainer); |
| 1 | 33 | | Assert.NotNull(viewContainer.GetComponent<MinimapHUDView>()); |
| 1 | 34 | | } |
| | 35 | |
|
| | 36 | | [Test] |
| | 37 | | public void MinimapHUD_DefaultSceneName() |
| | 38 | | { |
| 1 | 39 | | var view = controller.view; |
| 1 | 40 | | Assert.AreEqual("Unnamed", Reflection_GetField<TextMeshProUGUI>(view, "sceneNameText").text); |
| 1 | 41 | | } |
| | 42 | |
|
| | 43 | | [Test] |
| | 44 | | public void MinimapHUD_DefaultPlayerCoordinates() |
| | 45 | | { |
| 1 | 46 | | var view = controller.view; |
| 1 | 47 | | Assert.IsEmpty(Reflection_GetField<TextMeshProUGUI>(view, "playerPositionText").text); |
| 1 | 48 | | } |
| | 49 | |
|
| | 50 | | [Test] |
| | 51 | | public void MinimapHUD_SetSceneName() |
| | 52 | | { |
| | 53 | | const string sceneName = "SCENE_NAME"; |
| | 54 | |
|
| 1 | 55 | | controller.UpdateSceneName(sceneName); |
| 1 | 56 | | var view = controller.view; |
| 1 | 57 | | Assert.AreEqual(sceneName, Reflection_GetField<TextMeshProUGUI>(view, "sceneNameText").text); |
| 1 | 58 | | } |
| | 59 | |
|
| | 60 | | [Test] |
| | 61 | | public void MinimapHUD_SetPlayerCoordinatesVector2() |
| | 62 | | { |
| 1 | 63 | | Vector2 coords = new Vector2(Random.Range(-150, 150), Random.Range(-150, 150)); |
| 1 | 64 | | string coordString = string.Format("{0},{1}", coords.x, coords.y); |
| | 65 | |
|
| 1 | 66 | | controller.UpdatePlayerPosition(coords); |
| 1 | 67 | | Assert.AreEqual(coordString, Reflection_GetField<TextMeshProUGUI>(this.controller.view, "playerPositionText" |
| 1 | 68 | | } |
| | 69 | |
|
| | 70 | | [Test] |
| | 71 | | public void MinimapHUD_SetPlayerCoordinatesString() |
| | 72 | | { |
| 1 | 73 | | Vector2 coords = new Vector2(Random.Range(-150, 150), Random.Range(-150, 150)); |
| 1 | 74 | | string coordString = string.Format("{0},{1}", coords.x, coords.y); |
| | 75 | |
|
| 1 | 76 | | controller.UpdatePlayerPosition(coordString); |
| 1 | 77 | | Assert.AreEqual(coordString, Reflection_GetField<TextMeshProUGUI>(this.controller.view, "playerPositionText" |
| 1 | 78 | | } |
| | 79 | |
|
| | 80 | | [Test] |
| 2 | 81 | | public void MinimapHUD_OptionsPanel() { Assert.IsNotNull(controller); } |
| | 82 | | } |
| | 83 | | } |