< Summary

Class:BuildModeConfirmationModalController
Assembly:BuildModeHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/BuildModeHUD/Scripts/Common/BuildModeConfirmationModalController.cs
Covered lines:22
Uncovered lines:0
Coverable lines:22
Total lines:73
Line coverage:100% (22 of 22)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Initialize(...)0%110100%
Dispose()0%110100%
Configure(...)0%110100%
IsViewActive()0%110100%
SetActive(...)0%110100%
CancelExit()0%220100%
ConfirmExit()0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/BuildModeHUD/Scripts/Common/BuildModeConfirmationModalController.cs

#LineLine coverage
 1using System;
 2using UnityEngine;
 3
 4public enum BuildModeModalType
 5{
 6    EXIT,
 7    PUBLISH
 8}
 9
 10public interface IBuildModeConfirmationModalController
 11{
 12    event Action<BuildModeModalType> OnCancelExit;
 13    event Action<BuildModeModalType> OnConfirmExit;
 14
 15    bool IsViewActive();
 16    void Initialize(IBuildModeConfirmationModalView exitFromBiWModalView);
 17    void Dispose();
 18    void Configure(string titleText, string subTitleText, string cancelBtnText, string confirmBtnText);
 19    void SetActive(bool isActive, BuildModeModalType modalType);
 20    void CancelExit();
 21    void ConfirmExit();
 22}
 23
 24public class BuildModeConfirmationModalController : IBuildModeConfirmationModalController
 25{
 26    public event Action<BuildModeModalType> OnCancelExit;
 27    public event Action<BuildModeModalType> OnConfirmExit;
 28
 29    internal IBuildModeConfirmationModalView exitFromBiWModalView;
 30    internal BuildModeModalType modalType;
 31
 32    public void Initialize(IBuildModeConfirmationModalView exitFromBiWModalView)
 33    {
 634        this.exitFromBiWModalView = exitFromBiWModalView;
 35
 636        exitFromBiWModalView.OnCancelExit += CancelExit;
 637        exitFromBiWModalView.OnConfirmExit += ConfirmExit;
 638    }
 39
 40    public void Dispose()
 41    {
 642        exitFromBiWModalView.OnCancelExit -= CancelExit;
 643        exitFromBiWModalView.OnConfirmExit -= ConfirmExit;
 644    }
 45
 46    public void Configure(string titleText, string subTitleText, string cancelBtnText, string confirmBtnText)
 47    {
 148        exitFromBiWModalView.SetTitle(titleText);
 149        exitFromBiWModalView.SetSubTitle(subTitleText);
 150        exitFromBiWModalView.SetCancelButtonText(cancelBtnText);
 151        exitFromBiWModalView.SetConfirmButtonText(confirmBtnText);
 152    }
 53
 154    public bool IsViewActive() { return exitFromBiWModalView.IsActive(); }
 55
 56    public void SetActive(bool isActive, BuildModeModalType modalType)
 57    {
 458        this.modalType = modalType;
 459        exitFromBiWModalView.SetActive(isActive);
 460    }
 61
 62    public void CancelExit()
 63    {
 164        SetActive(false, modalType);
 165        OnCancelExit?.Invoke(modalType);
 166    }
 67
 68    public void ConfirmExit()
 69    {
 170        SetActive(false, modalType);
 171        OnConfirmExit?.Invoke(modalType);
 172    }
 73}