< Summary

Class:DCL.Chat.HUD.LeaveChannelConfirmationWindowController
Assembly:WorldChatWindowHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/WorldChatWindowHUD/LeaveChannelConfirmationWindowController.cs
Covered lines:24
Uncovered lines:4
Coverable lines:28
Total lines:67
Line coverage:85.7% (24 of 28)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
LeaveChannelConfirmationWindowController(...)0%110100%
Initialize(...)0%110100%
Dispose()0%110100%
SetChannelToLeave(...)0%110100%
SetVisibility(...)0%220100%
OnCancelLeave()0%110100%
OnConfirmLeave(...)0%110100%
HandleChannelLeft(...)0%2100%
HandleChannelLeaveError(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/WorldChatWindowHUD/LeaveChannelConfirmationWindowController.cs

#LineLine coverage
 1using DCL.Chat.Channels;
 2
 3namespace DCL.Chat.HUD
 4{
 5    public class LeaveChannelConfirmationWindowController : IHUD
 6    {
 7        internal ILeaveChannelConfirmationWindowComponentView joinChannelView;
 8        internal readonly IChatController chatController;
 9
 610        public LeaveChannelConfirmationWindowController(IChatController chatController)
 11        {
 612            this.chatController = chatController;
 13
 614            this.chatController.OnChannelLeft += HandleChannelLeft;
 615            this.chatController.OnChannelLeaveError += HandleChannelLeaveError;
 616        }
 17
 018        public ILeaveChannelConfirmationWindowComponentView View => joinChannelView;
 19
 20        public void Initialize(ILeaveChannelConfirmationWindowComponentView view)
 21        {
 622            joinChannelView = view;
 23
 624            joinChannelView.OnCancelLeave += OnCancelLeave;
 625            joinChannelView.OnConfirmLeave += OnConfirmLeave;
 626        }
 27
 28        public void Dispose()
 29        {
 630            chatController.OnChannelLeft -= HandleChannelLeft;
 631            chatController.OnChannelLeaveError -= HandleChannelLeaveError;
 632            joinChannelView.OnCancelLeave -= OnCancelLeave;
 633            joinChannelView.OnConfirmLeave -= OnConfirmLeave;
 634        }
 35
 36        public void SetChannelToLeave(string channelId)
 37        {
 238            joinChannelView.SetChannel(channelId);
 239        }
 40
 41        public void SetVisibility(bool visible)
 42        {
 243            if (visible)
 144                joinChannelView.Show();
 45            else
 146                joinChannelView.Hide();
 147        }
 48
 49        private void OnCancelLeave()
 50        {
 151            joinChannelView.Hide();
 152        }
 53
 54        private void OnConfirmLeave(string channelId)
 55        {
 156            chatController.LeaveChannel(channelId);
 157        }
 58
 59        private void HandleChannelLeft(string channelId)
 60        {
 061            joinChannelView.Hide();
 062        }
 63
 64        private void HandleChannelLeaveError(string channelId, ChannelErrorCode errorCode) =>
 065            joinChannelView.Hide();
 66    }
 67}