< Summary

Class:Tests.UnpublishPopupShould
Assembly:BuilderProjectsPanelTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuilderProjectsPanel/Tests/UnpublishPopupShould.cs
Covered lines:64
Uncovered lines:0
Coverable lines:64
Total lines:121
Line coverage:100% (64 of 64)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetUp()0%110100%
TearDown()0%110100%
ShowConfirmationPopupCorrectly()0%110100%
ShowProgressCorrectly()0%110100%
ShowErrorCorrectly()0%110100%
ShowSuccessCorrectly()0%110100%
ControllerSuccessFlowCorrectly()0%110100%
ControllerErrorFlowCorrectly()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuilderProjectsPanel/Tests/UnpublishPopupShould.cs

#LineLine coverage
 1using DCL;
 2using NUnit.Framework;
 3using UnityEditor;
 4using UnityEngine;
 5
 6namespace Tests
 7{
 8    public class UnpublishPopupShould
 9    {
 10        private UnpublishPopupView view;
 11        private UnpublishPopupController controller;
 12
 13        [SetUp]
 14        public void SetUp()
 15        {
 16            const string prefabAssetPath =
 17                "Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuilderProjectsPanel/Prefabs/UnpublishPopup/UnpublishPop
 618            var prefab = AssetDatabase.LoadAssetAtPath<UnpublishPopupView>(prefabAssetPath);
 619            view = UnityEngine.Object.Instantiate(prefab);
 620            controller = new UnpublishPopupController(view);
 621        }
 22
 23        [TearDown]
 1224        public void TearDown() { controller.Dispose(); }
 25
 26        [Test]
 27        public void ShowConfirmationPopupCorrectly()
 28        {
 129            controller.Show(Vector2Int.zero);
 130            Assert.IsTrue(view.gameObject.activeSelf);
 31
 132            Assert.IsTrue(view.cancelButton.gameObject.activeSelf);
 133            Assert.IsTrue(view.unpublishButton.gameObject.activeSelf);
 134            Assert.IsTrue(view.infoText.gameObject.activeSelf);
 135            Assert.IsTrue(view.closeButton.gameObject.activeSelf);
 136            Assert.IsFalse(view.doneButton.gameObject.activeSelf);
 137            Assert.IsFalse(view.errorText.gameObject.activeSelf);
 138            Assert.IsFalse(view.loadingBarContainer.gameObject.activeSelf);
 139        }
 40
 41        [Test]
 42        public void ShowProgressCorrectly()
 43        {
 144            IUnpublishPopupView iview = view;
 145            iview.SetProgress("", 0);
 146            Assert.AreEqual("0%", view.loadingText.text);
 147            iview.SetProgress("", 0.5f);
 148            Assert.AreEqual("50%", view.loadingText.text);
 49
 150            Assert.IsTrue(view.loadingBarContainer.gameObject.activeSelf);
 151            Assert.IsFalse(view.cancelButton.gameObject.activeSelf);
 152            Assert.IsFalse(view.unpublishButton.gameObject.activeSelf);
 153            Assert.IsFalse(view.infoText.gameObject.activeSelf);
 154            Assert.IsFalse(view.doneButton.gameObject.activeSelf);
 155            Assert.IsFalse(view.errorText.gameObject.activeSelf);
 156            Assert.IsFalse(view.closeButton.gameObject.activeSelf);
 157        }
 58
 59        [Test]
 60        public void ShowErrorCorrectly()
 61        {
 62            const string error = "Some Error";
 63
 164            IUnpublishPopupView iview = view;
 165            iview.SetError("", error);
 166            Assert.AreEqual(error, view.errorText.text);
 67
 168            Assert.IsFalse(view.loadingBarContainer.gameObject.activeSelf);
 169            Assert.IsFalse(view.cancelButton.gameObject.activeSelf);
 170            Assert.IsFalse(view.unpublishButton.gameObject.activeSelf);
 171            Assert.IsFalse(view.infoText.gameObject.activeSelf);
 172            Assert.IsTrue(view.doneButton.gameObject.activeSelf);
 173            Assert.IsTrue(view.errorText.gameObject.activeSelf);
 174            Assert.IsTrue(view.closeButton.gameObject.activeSelf);
 175        }
 76
 77        [Test]
 78        public void ShowSuccessCorrectly()
 79        {
 80            const string success = "Some Success Message";
 81
 182            IUnpublishPopupView iview = view;
 183            iview.SetSuccess("", success);
 184            Assert.AreEqual(success, view.infoText.text);
 85
 186            Assert.IsTrue(view.infoText.gameObject.activeSelf);
 187            Assert.IsTrue(view.doneButton.gameObject.activeSelf);
 188            Assert.IsFalse(view.loadingBarContainer.gameObject.activeSelf);
 189            Assert.IsFalse(view.cancelButton.gameObject.activeSelf);
 190            Assert.IsFalse(view.unpublishButton.gameObject.activeSelf);
 191            Assert.IsFalse(view.errorText.gameObject.activeSelf);
 192            Assert.IsTrue(view.closeButton.gameObject.activeSelf);
 193        }
 94
 95        [Test]
 96        public void ControllerSuccessFlowCorrectly()
 97        {
 198            controller.Show(Vector2Int.zero);
 199            Assert.AreEqual(UnpublishPopupView.State.CONFIRM_UNPUBLISH, view.state);
 100
 1101            view.unpublishButton.onClick.Invoke();
 1102            Assert.AreEqual(UnpublishPopupView.State.UNPUBLISHING, view.state);
 103
 1104            DataStore.i.builderInWorld.unpublishSceneResult.Set(new PublishSceneResultPayload() { ok = true }, true);
 1105            Assert.AreEqual(UnpublishPopupView.State.DONE_UNPUBLISH, view.state);
 1106        }
 107
 108        [Test]
 109        public void ControllerErrorFlowCorrectly()
 110        {
 1111            controller.Show(Vector2Int.zero);
 1112            Assert.AreEqual(UnpublishPopupView.State.CONFIRM_UNPUBLISH, view.state);
 113
 1114            view.unpublishButton.onClick.Invoke();
 1115            Assert.AreEqual(UnpublishPopupView.State.UNPUBLISHING, view.state);
 116
 1117            DataStore.i.builderInWorld.unpublishSceneResult.Set(new PublishSceneResultPayload() { ok = false }, true);
 1118            Assert.AreEqual(UnpublishPopupView.State.ERROR_UNPUBLISH, view.state);
 1119        }
 120    }
 121}