< Summary

Class:DCL.ConfirmationPopup.ConfirmationPopupHUDController
Assembly:ConfirmationPopup
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/ConfirmationPopup/ConfirmationPopupHUDController.cs
Covered lines:34
Uncovered lines:0
Coverable lines:34
Total lines:72
Line coverage:100% (34 of 34)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
ConfirmationPopupHUDController(...)0%110100%
Dispose()0%110100%
OnCancelFromView()0%220100%
OnConfirmFromView()0%220100%
ShowOrHide(...)0%220100%
Hide()0%110100%
Show(...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/ConfirmationPopup/ConfirmationPopupHUDController.cs

#LineLine coverage
 1using System;
 2
 3namespace DCL.ConfirmationPopup
 4{
 5    public class ConfirmationPopupHUDController : IDisposable
 6    {
 7        private readonly IConfirmationPopupHUDView view;
 8        private readonly DataStore_Notifications dataStore;
 9
 10        private Action externalConfirmationAction;
 11        private Action externalCancelAction;
 12
 413        public ConfirmationPopupHUDController(IConfirmationPopupHUDView view,
 14            DataStore_Notifications dataStore)
 15        {
 416            this.view = view;
 417            this.dataStore = dataStore;
 18
 419            this.view.OnConfirm += OnConfirmFromView;
 420            this.view.OnCancel += OnCancelFromView;
 21
 422            this.dataStore.GenericConfirmation.OnChange += ShowOrHide;
 23
 424            view.Hide(true);
 425        }
 26
 27        public void Dispose()
 28        {
 429            dataStore.GenericConfirmation.OnChange -= ShowOrHide;
 430            view.OnConfirm -= OnConfirmFromView;
 431            view.OnCancel -= OnCancelFromView;
 432            view.Dispose();
 433            externalCancelAction = null;
 434            externalConfirmationAction = null;
 435        }
 36
 37        private void OnCancelFromView()
 38        {
 139            externalCancelAction?.Invoke();
 140            Hide();
 141        }
 42
 43        private void OnConfirmFromView()
 44        {
 145            externalConfirmationAction?.Invoke();
 146            Hide();
 147        }
 48
 49        private void ShowOrHide(GenericConfirmationNotificationData current, GenericConfirmationNotificationData previou
 50        {
 451            if (current == null)
 152                Hide();
 53            else
 354                Show(current);
 355        }
 56
 57        private void Hide()
 58        {
 359            externalCancelAction = null;
 360            externalConfirmationAction = null;
 361            view.Hide();
 362        }
 63
 64        private void Show(GenericConfirmationNotificationData data)
 65        {
 366            externalCancelAction = data.CancelAction;
 367            externalConfirmationAction = data.ConfirmAction;
 368            view.SetModel(new ConfirmationPopupHUDViewModel(data.Title, data.Body, data.CancelButton, data.ConfirmButton
 369            view.Show();
 370        }
 71    }
 72}