| | 1 | | using System.Collections; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using NSubstitute; |
| | 4 | | using NUnit.Framework; |
| | 5 | | using UnityEngine.TestTools; |
| | 6 | |
|
| | 7 | | namespace Tests |
| | 8 | | { |
| | 9 | | public class NFTPromptHUDTests |
| | 10 | | { |
| | 11 | | private NFTPromptHUDController controller; |
| | 12 | | private NFTPromptHUDView view; |
| | 13 | |
|
| | 14 | | [SetUp] |
| | 15 | | public void SetUp() |
| | 16 | | { |
| 6 | 17 | | controller = new NFTPromptHUDController(); |
| 6 | 18 | | view = (NFTPromptHUDView)controller.view; |
| 6 | 19 | | } |
| | 20 | |
|
| | 21 | | [TearDown] |
| 12 | 22 | | public void TearDown() { controller.Dispose(); } |
| | 23 | |
|
| | 24 | | [Test] |
| | 25 | | public void CreateView() |
| | 26 | | { |
| 1 | 27 | | Assert.NotNull(view); |
| 1 | 28 | | Assert.NotNull(view.gameObject); |
| 1 | 29 | | } |
| | 30 | |
|
| | 31 | | [Test] |
| | 32 | | public void OpenAndCloseCorrectly() |
| | 33 | | { |
| 1 | 34 | | controller.OpenNftInfoDialog(new NFTPromptModel("0xf64dc33a192e056bb5f0e5049356a0498b502d50", |
| | 35 | | "2481", null), null); |
| 1 | 36 | | Assert.IsTrue(view.content.activeSelf, "NFT dialog should be visible"); |
| 1 | 37 | | view.buttonClose.onClick.Invoke(); |
| 1 | 38 | | Assert.IsFalse(view.content.activeSelf, "NFT dialog should not be visible"); |
| 1 | 39 | | } |
| | 40 | |
|
| | 41 | | [Test] |
| | 42 | | public void OwnersTooltipSetupCorrectly() |
| | 43 | | { |
| 1 | 44 | | var tooltip = view.ownersTooltip; |
| 1 | 45 | | Assert.AreEqual(0, tooltip.ownerElementsContainer.childCount); |
| 1 | 46 | | } |
| | 47 | |
|
| | 48 | | [Test] |
| | 49 | | public void OwnersTooltipShowCorrectly() |
| | 50 | | { |
| 1 | 51 | | var tooltip = view.ownersTooltip; |
| 1 | 52 | | IOwnersTooltipView tooltipView = tooltip; |
| | 53 | |
|
| 1 | 54 | | List<IOwnerInfoElement> owners = new List<IOwnerInfoElement>(); |
| 12 | 55 | | for (int i = 0; i < OwnersTooltipView.MAX_ELEMENTS; i++) |
| | 56 | | { |
| 5 | 57 | | owners.Add(Substitute.For<IOwnerInfoElement>()); |
| | 58 | | } |
| | 59 | |
|
| 1 | 60 | | tooltipView.SetElements(owners); |
| 1 | 61 | | Assert.IsFalse(tooltip.viewAllButton.gameObject.activeSelf, "View All button shouldn't be active"); |
| | 62 | |
|
| 1 | 63 | | owners.Add(Substitute.For<IOwnerInfoElement>()); |
| 1 | 64 | | tooltipView.SetElements(owners); |
| | 65 | |
|
| 1 | 66 | | Assert.IsTrue(tooltip.viewAllButton.gameObject.activeSelf, "View All button should be active"); |
| | 67 | |
|
| 1 | 68 | | tooltipView.Show(); |
| 1 | 69 | | Assert.IsTrue(tooltipView.IsActive()); |
| 1 | 70 | | tooltipView.Hide(true); |
| 1 | 71 | | Assert.IsFalse(tooltipView.IsActive()); |
| 1 | 72 | | } |
| | 73 | |
|
| | 74 | | [Test] |
| | 75 | | public void OwnersPopupSetupCorrectly() |
| | 76 | | { |
| 1 | 77 | | var popup = view.ownersPopup; |
| 1 | 78 | | Assert.AreEqual(0, popup.ownerElementsContainer.childCount); |
| 1 | 79 | | } |
| | 80 | |
|
| | 81 | | [Test] |
| | 82 | | public void OwnersPopupShowCorrectly() |
| | 83 | | { |
| 1 | 84 | | var popup = view.ownersPopup; |
| | 85 | | IOwnersPopupView popupView = popup; |
| | 86 | |
|
| 1 | 87 | | popupView.Show(); |
| 1 | 88 | | Assert.IsTrue(popupView.IsActive()); |
| 1 | 89 | | popupView.Hide(true); |
| 1 | 90 | | Assert.IsFalse(popupView.IsActive()); |
| 1 | 91 | | } |
| | 92 | | } |
| | 93 | | } |