< Summary

Class:Tests.SignupHUD.SignupHUDControllerShould
Assembly:SignupHUDTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/SignupHUD/Tests/SignupHUDControllerShould.cs
Covered lines:49
Uncovered lines:1
Coverable lines:50
Total lines:111
Line coverage:98% (49 of 50)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetUp()0%110100%
InitializeProperly()0%110100%
ReactToSignupVisibleTrue()0%110100%
ReactToSignupVisibleFalse()0%110100%
StartSignupProcessProperly()0%110100%
ReactsToNameScreenNextProperly()0%110100%
ReactsToEditAvatarProperly()0%110100%
ReactsToTermsOfServiceAgreed()0%110100%
ReactsToTermsOfServiceBack()0%110100%
TearDown()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/SignupHUD/Tests/SignupHUDControllerShould.cs

#LineLine coverage
 1using System;
 2using DCL;
 3using NSubstitute;
 4using NSubstitute.Extensions;
 5using NUnit.Framework;
 6using SignupHUD;
 7
 8namespace Tests.SignupHUD
 9{
 10    public class SignupHUDControllerShould
 11    {
 12        private SignupHUDController hudController;
 13        private ISignupHUDView hudView;
 14        private IHUD avatarEditorHUD;
 015        private BaseVariable<bool> signupVisible => DataStore.i.HUDs.signupVisible;
 16
 17        [SetUp]
 18        public void SetUp()
 19        {
 820            hudView = Substitute.For<ISignupHUDView>();
 821            avatarEditorHUD = Substitute.For<IHUD>();
 822            hudController = Substitute.ForPartsOf<SignupHUDController>();
 1623            hudController.Configure().CreateView().Returns(info => hudView);
 824            hudController.Initialize(avatarEditorHUD);
 825        }
 26
 27        [Test]
 28        public void InitializeProperly()
 29        {
 130            Assert.AreEqual(hudView, hudController.view);
 131            Assert.AreEqual(avatarEditorHUD, hudController.avatarEditorHUD);
 132            Assert.IsFalse(signupVisible.Get());
 133        }
 34
 35        [Test]
 36        public void ReactToSignupVisibleTrue()
 37        {
 138            hudController.name = "this_will_be_null";
 139            hudController.email = "this_will_be_null";
 40
 141            signupVisible.Set(true, true); //Force event notification
 42
 143            hudView.Received().SetVisibility(true);
 144            Assert.IsNull(hudController.name);
 145            Assert.IsNull(hudController.email);
 146            hudView.Received().ShowNameScreen();
 147        }
 48
 49        [Test]
 50        public void ReactToSignupVisibleFalse()
 51        {
 152            signupVisible.Set(false, true); //Force event notification
 153            hudView.Received().SetVisibility(false);
 154        }
 55
 56        [Test]
 57        public void StartSignupProcessProperly()
 58        {
 159            hudController.name = "this_will_be_null";
 160            hudController.email = "this_will_be_null";
 61
 162            hudController.StartSignupProcess();
 63
 164            Assert.IsNull(hudController.name);
 165            Assert.IsNull(hudController.email);
 166            hudView.Received().ShowNameScreen();
 167        }
 68
 69        [Test]
 70        public void ReactsToNameScreenNextProperly()
 71        {
 172            hudView.OnNameScreenNext += Raise.Event<ISignupHUDView.NameScreenDone>("new_name", "new_email");
 173            Assert.AreEqual(hudController.name, "new_name");
 174            Assert.AreEqual(hudController.email, "new_email");
 175            hudView.Received().ShowTermsOfServiceScreen();
 176        }
 77
 78        [Test]
 79        public void ReactsToEditAvatarProperly()
 80        {
 181            hudView.OnEditAvatar += Raise.Event<Action>();
 182            Assert.IsFalse(signupVisible.Get());
 183            avatarEditorHUD.Received().SetVisibility(true);
 184        }
 85
 86        [Test]
 87        public void ReactsToTermsOfServiceAgreed()
 88        {
 189            hudView.OnTermsOfServiceAgreed += Raise.Event<Action>();
 90            //TODO assert webinterface interaction
 191            Assert.IsFalse(signupVisible.Get());
 192            Assert.IsFalse(DataStore.i.isSignUpFlow.Get());
 193        }
 94
 95        [Test]
 96        public void ReactsToTermsOfServiceBack()
 97        {
 198            hudController.name = "this_will_be_null";
 199            hudController.email = "this_will_be_null";
 100
 1101            hudView.OnTermsOfServiceBack += Raise.Event<Action>();
 102
 1103            Assert.IsNull(hudController.name);
 1104            Assert.IsNull(hudController.email);
 1105            hudView.Received().ShowNameScreen();
 1106        }
 107
 108        [TearDown]
 16109        public void TearDown() { DataStore.Clear(); }
 110    }
 111}