< Summary

Class:DCL.MyAccount.MyAccountCardController
Assembly:MyAccountHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/MyAccountHUD/MyAccountCardController.cs
Covered lines:36
Uncovered lines:1
Coverable lines:37
Total lines:84
Line coverage:97.2% (36 of 37)
Covered branches:0
Total branches:0
Covered methods:8
Total methods:8
Method coverage:100% (8 of 8)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
MyAccountCardController(...)0%220100%
Dispose()0%110100%
OnOwnUserProfileUpdate(...)0%2.062075%
OnPreviewProfileClicked()0%110100%
OnAccountSettingsClicked()0%110100%
OnSignOutClicked()0%220100%
OnTermsOfServiceClicked()0%110100%
OnPrivacyPolicyClicked()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/MyAccountHUD/MyAccountCardController.cs

#LineLine coverage
 1using DCL.Browser;
 2using DCL.SettingsCommon;
 3using System;
 4
 5namespace DCL.MyAccount
 6{
 7    public class MyAccountCardController
 8    {
 9        private const string OPEN_PASSPORT_SOURCE = "ProfileHUD";
 10        private const string URL_TERMS_OF_USE = "https://decentraland.org/terms";
 11        private const string URL_PRIVACY_POLICY = "https://decentraland.org/privacy";
 12
 13        private readonly IMyAccountCardComponentView view;
 14        private readonly DataStore dataStore;
 15        private readonly IUserProfileBridge userProfileBridge;
 16        private readonly Settings settings;
 17        private readonly IBrowserBridge browserBridge;
 18
 1119        public MyAccountCardController(
 20            IMyAccountCardComponentView view,
 21            DataStore dataStore,
 22            IUserProfileBridge userProfileBridge,
 23            Settings settings,
 24            IBrowserBridge browserBridge)
 25        {
 1126            this.view = view;
 1127            this.dataStore = dataStore;
 1128            this.userProfileBridge = userProfileBridge;
 1129            this.settings = settings;
 1130            this.browserBridge = browserBridge;
 31
 1132            view.OnPreviewProfileClicked += OnPreviewProfileClicked;
 1133            view.OnAccountSettingsClicked += OnAccountSettingsClicked;
 1134            view.OnSignOutClicked += OnSignOutClicked;
 1135            view.OnTermsOfServiceClicked += OnTermsOfServiceClicked;
 1136            view.OnPrivacyPolicyClicked += OnPrivacyPolicyClicked;
 37
 1138            userProfileBridge.GetOwn().OnUpdate += OnOwnUserProfileUpdate;
 1139            bool isProfileInitialized = !string.IsNullOrEmpty(userProfileBridge.GetOwn().userId);
 1140            if (isProfileInitialized)
 541                OnOwnUserProfileUpdate(userProfileBridge.GetOwn());
 1142        }
 43
 44        public void Dispose()
 45        {
 1146            view.OnPreviewProfileClicked -= OnPreviewProfileClicked;
 1147            view.OnAccountSettingsClicked -= OnAccountSettingsClicked;
 1148            view.OnSignOutClicked -= OnSignOutClicked;
 1149            view.OnTermsOfServiceClicked -= OnTermsOfServiceClicked;
 1150            view.OnPrivacyPolicyClicked -= OnPrivacyPolicyClicked;
 1151            userProfileBridge.GetOwn().OnUpdate -= OnOwnUserProfileUpdate;
 1152        }
 53
 54        private void OnOwnUserProfileUpdate(UserProfile userProfile)
 55        {
 556            if (userProfile == null)
 057                return;
 58
 559            view.SetSignOutButtonActive(!userProfile.isGuest);
 560        }
 61
 62        private void OnPreviewProfileClicked()
 63        {
 164            dataStore.HUDs.currentPlayerId.Set((userProfileBridge.GetOwn().userId, OPEN_PASSPORT_SOURCE));
 165            dataStore.exploreV2.profileCardIsOpen.Set(false);
 166            view.Hide();
 167        }
 68
 69        private void OnAccountSettingsClicked() =>
 170            dataStore.myAccount.myAccountSectionOpenFromProfileHUD.Set(true, true);
 71
 72        private void OnSignOutClicked()
 73        {
 174            settings?.SaveSettings();
 175            userProfileBridge.LogOut();
 176        }
 77
 78        private void OnTermsOfServiceClicked() =>
 179            browserBridge.OpenUrl(URL_TERMS_OF_USE);
 80
 81        private void OnPrivacyPolicyClicked() =>
 182            browserBridge.OpenUrl(URL_PRIVACY_POLICY);
 83    }
 84}