| | 1 | | using NUnit.Framework; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | namespace Tests.BuildModeHUDViews |
| | 5 | | { |
| | 6 | | public class TooltipViewShould |
| | 7 | | { |
| | 8 | | private TooltipView tooltipView; |
| | 9 | |
|
| | 10 | | [SetUp] |
| 6 | 11 | | public void SetUp() { tooltipView = TooltipView.Create(); } |
| | 12 | |
|
| | 13 | | [TearDown] |
| 6 | 14 | | public void TearDown() { Object.Destroy(tooltipView.gameObject); } |
| | 15 | |
|
| | 16 | | [Test] |
| | 17 | | public void SetTooltipPositionProperly() |
| | 18 | | { |
| | 19 | | // Arrange |
| 1 | 20 | | Vector3 oldPosition = new Vector3(0, 0, 0); |
| 1 | 21 | | Vector3 newPosition = new Vector3(5, 2, 0); |
| 1 | 22 | | tooltipView.tooltipRT.position = oldPosition; |
| | 23 | |
|
| | 24 | | // Act |
| 1 | 25 | | tooltipView.SetTooltipPosition(newPosition); |
| | 26 | |
|
| | 27 | | // Assert |
| 1 | 28 | | Assert.AreEqual(newPosition, tooltipView.tooltipRT.position, "The tooltip position does not match!"); |
| 1 | 29 | | } |
| | 30 | |
|
| | 31 | | [Test] |
| | 32 | | public void SetTextProperly() |
| | 33 | | { |
| | 34 | | // Arrange |
| 1 | 35 | | string oldText = "Old text"; |
| 1 | 36 | | string newText = "New text"; |
| 1 | 37 | | tooltipView.tooltipTxt.text = oldText; |
| | 38 | |
|
| | 39 | | // Act |
| 1 | 40 | | tooltipView.SetText(newText); |
| | 41 | |
|
| | 42 | | // Assert |
| 1 | 43 | | Assert.AreEqual(newText, tooltipView.tooltipTxt.text, "The tooltip text does not match!"); |
| 1 | 44 | | } |
| | 45 | |
|
| | 46 | | [Test] |
| | 47 | | public void SetTooltipAlphaProperly() |
| | 48 | | { |
| | 49 | | // Arrange |
| 1 | 50 | | float oldAlpha = 0f; |
| 1 | 51 | | float newAlpha = 0.5f; |
| 1 | 52 | | tooltipView.tooltipCG.alpha = oldAlpha; |
| | 53 | |
|
| | 54 | | // Act |
| 1 | 55 | | tooltipView.SetTooltipAlpha(newAlpha); |
| | 56 | |
|
| | 57 | | // Assert |
| 1 | 58 | | Assert.AreEqual(newAlpha, tooltipView.tooltipCG.alpha, "The tooltip alpha does not match!"); |
| 1 | 59 | | } |
| | 60 | | } |
| | 61 | | } |