< Summary

Class:DCL.Social.Chat.ChannelLeaveErrorWindowController
Assembly:WorldChatWindowHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/WorldChatWindowHUD/ChannelLeaveErrorWindowController.cs
Covered lines:18
Uncovered lines:6
Coverable lines:24
Total lines:53
Line coverage:75% (18 of 24)
Covered branches:0
Total branches:0
Covered methods:4
Total methods:5
Method coverage:80% (4 of 5)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
ChannelLeaveErrorWindowController(...)0%110100%
Dispose()0%6200%
Show(...)0%5.125083.33%
Close()0%110100%
Retry()0%110100%

File(s)

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

#LineLine coverage
 1using DCL.Social.Chat;
 2
 3namespace DCL.Social.Chat
 4{
 5    public class ChannelLeaveErrorWindowController
 6    {
 7        private readonly IChannelLeaveErrorWindowView view;
 8        private readonly IChatController chatController;
 9        private readonly DataStore dataStore;
 10        private string currentChannelId;
 11
 312        public ChannelLeaveErrorWindowController(IChannelLeaveErrorWindowView view,
 13            IChatController chatController,
 14            DataStore dataStore)
 15        {
 316            this.view = view;
 317            this.chatController = chatController;
 318            view.Hide();
 319            view.OnClose += Close;
 320            view.OnRetry += Retry;
 321            this.dataStore = dataStore;
 322            dataStore.channels.leaveChannelError.OnChange += Show;
 323        }
 24
 25        public void Dispose()
 26        {
 027            dataStore.channels.leaveChannelError.OnChange -= Show;
 28
 029            if (view != null)
 30            {
 031                view.OnClose -= Close;
 032                view.OnRetry -= Retry;
 033                view.Dispose();
 34            }
 035        }
 36
 37        private void Show(string currentChannelId, string previousChannelId)
 38        {
 539            if (string.IsNullOrEmpty(currentChannelId)) return;
 540            this.currentChannelId = currentChannelId;
 541            var channel = chatController.GetAllocatedChannel(currentChannelId);
 542            view.Show(channel?.Name ?? currentChannelId);
 543        }
 44
 245        private void Close() => view.Hide();
 46
 47        private void Retry()
 48        {
 149            chatController.LeaveChannel(currentChannelId);
 150            Close();
 151        }
 52    }
 53}