| | 1 | | using NSubstitute; |
| | 2 | | using NUnit.Framework; |
| | 3 | | using UnityEngine.EventSystems; |
| | 4 | |
|
| | 5 | | namespace Tests.BuildModeHUDControllers |
| | 6 | | { |
| | 7 | | public class FirstPersonModeControllerShould |
| | 8 | | { |
| | 9 | | private FirstPersonModeController firstPersonModeController; |
| | 10 | |
|
| | 11 | | [SetUp] |
| | 12 | | public void SetUp() |
| | 13 | | { |
| 3 | 14 | | firstPersonModeController = new FirstPersonModeController(); |
| 3 | 15 | | firstPersonModeController.Initialize( |
| | 16 | | Substitute.For<IFirstPersonModeView>(), |
| | 17 | | Substitute.For< ITooltipController>()); |
| 3 | 18 | | } |
| | 19 | |
|
| | 20 | | [TearDown] |
| 6 | 21 | | public void TearDown() { firstPersonModeController.Dispose(); } |
| | 22 | |
|
| | 23 | | [Test] |
| | 24 | | public void ClickCorrectly() |
| | 25 | | { |
| | 26 | | // Arrange |
| 1 | 27 | | bool clicked = false; |
| 3 | 28 | | firstPersonModeController.OnClick += () => { clicked = true; }; |
| | 29 | |
|
| | 30 | | // Act |
| 1 | 31 | | firstPersonModeController.Click(); |
| | 32 | |
|
| | 33 | | // Assert |
| 1 | 34 | | Assert.IsTrue(clicked, "clicked is false!"); |
| 1 | 35 | | } |
| | 36 | |
|
| | 37 | | [Test] |
| | 38 | | public void ShowTooltipCorrectly() |
| | 39 | | { |
| | 40 | | // Arrange |
| 1 | 41 | | BaseEventData testEventData = new BaseEventData(null); |
| 1 | 42 | | string testText = "Test text"; |
| | 43 | |
|
| | 44 | | // Act |
| 1 | 45 | | firstPersonModeController.ShowTooltip(testEventData, testText); |
| | 46 | |
|
| | 47 | | // Assert |
| 1 | 48 | | firstPersonModeController.tooltipController.Received(1).ShowTooltip(testEventData); |
| 1 | 49 | | firstPersonModeController.tooltipController.Received(1).SetTooltipText(testText); |
| 1 | 50 | | } |
| | 51 | |
|
| | 52 | | [Test] |
| | 53 | | public void HideTooltipCorrectly() |
| | 54 | | { |
| | 55 | | // Act |
| 1 | 56 | | firstPersonModeController.HideTooltip(); |
| | 57 | |
|
| | 58 | | // Assert |
| 1 | 59 | | firstPersonModeController.tooltipController.Received(1).HideTooltip(); |
| 1 | 60 | | } |
| | 61 | | } |
| | 62 | | } |