< Summary

Class:Tests.NFTPromptHUDTests
Assembly:NFTPromptHUDTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/NFTPromptHUD/Tests/NFTPromptHUDTests.cs
Covered lines:39
Uncovered lines:0
Coverable lines:39
Total lines:93
Line coverage:100% (39 of 39)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetUp()0%110100%
TearDown()0%110100%
CreateView()0%110100%
OpenAndCloseCorrectly()0%110100%
OwnersTooltipSetupCorrectly()0%110100%
OwnersTooltipShowCorrectly()0%220100%
OwnersPopupSetupCorrectly()0%110100%
OwnersPopupShowCorrectly()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/NFTPromptHUD/Tests/NFTPromptHUDTests.cs

#LineLine coverage
 1using System.Collections;
 2using System.Collections.Generic;
 3using NSubstitute;
 4using NUnit.Framework;
 5using UnityEngine.TestTools;
 6
 7namespace Tests
 8{
 9    public class NFTPromptHUDTests
 10    {
 11        private NFTPromptHUDController controller;
 12        private NFTPromptHUDView view;
 13
 14        [SetUp]
 15        public void SetUp()
 16        {
 617            controller = new NFTPromptHUDController();
 618            view = (NFTPromptHUDView)controller.view;
 619        }
 20
 21        [TearDown]
 1222        public void TearDown() { controller.Dispose(); }
 23
 24        [Test]
 25        public void CreateView()
 26        {
 127            Assert.NotNull(view);
 128            Assert.NotNull(view.gameObject);
 129        }
 30
 31        [Test]
 32        public void OpenAndCloseCorrectly()
 33        {
 134            controller.OpenNftInfoDialog(new NFTPromptModel("0xf64dc33a192e056bb5f0e5049356a0498b502d50",
 35                "2481", null), null);
 136            Assert.IsTrue(view.content.activeSelf, "NFT dialog should be visible");
 137            view.buttonClose.onClick.Invoke();
 138            Assert.IsFalse(view.content.activeSelf, "NFT dialog should not be visible");
 139        }
 40
 41        [Test]
 42        public void OwnersTooltipSetupCorrectly()
 43        {
 144            var tooltip = view.ownersTooltip;
 145            Assert.AreEqual(0, tooltip.ownerElementsContainer.childCount);
 146        }
 47
 48        [Test]
 49        public void OwnersTooltipShowCorrectly()
 50        {
 151            var tooltip = view.ownersTooltip;
 152            IOwnersTooltipView tooltipView = tooltip;
 53
 154            List<IOwnerInfoElement> owners = new List<IOwnerInfoElement>();
 1255            for (int i = 0; i < OwnersTooltipView.MAX_ELEMENTS; i++)
 56            {
 557                owners.Add(Substitute.For<IOwnerInfoElement>());
 58            }
 59
 160            tooltipView.SetElements(owners);
 161            Assert.IsFalse(tooltip.viewAllButton.gameObject.activeSelf, "View All button shouldn't be active");
 62
 163            owners.Add(Substitute.For<IOwnerInfoElement>());
 164            tooltipView.SetElements(owners);
 65
 166            Assert.IsTrue(tooltip.viewAllButton.gameObject.activeSelf, "View All button should be active");
 67
 168            tooltipView.Show();
 169            Assert.IsTrue(tooltipView.IsActive());
 170            tooltipView.Hide(true);
 171            Assert.IsFalse(tooltipView.IsActive());
 172        }
 73
 74        [Test]
 75        public void OwnersPopupSetupCorrectly()
 76        {
 177            var popup = view.ownersPopup;
 178            Assert.AreEqual(0, popup.ownerElementsContainer.childCount);
 179        }
 80
 81        [Test]
 82        public void OwnersPopupShowCorrectly()
 83        {
 184            var popup = view.ownersPopup;
 85            IOwnersPopupView popupView = popup;
 86
 187            popupView.Show();
 188            Assert.IsTrue(popupView.IsActive());
 189            popupView.Hide(true);
 190            Assert.IsFalse(popupView.IsActive());
 191        }
 92    }
 93}