< Summary

Class:DCL.Social.Chat.ChannelJoinErrorWindowController
Assembly:WorldChatWindowHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/WorldChatWindowHUD/ChannelJoinErrorWindowController.cs
Covered lines:18
Uncovered lines:6
Coverable lines:24
Total lines:54
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
ChannelJoinErrorWindowController(...)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/ChannelJoinErrorWindowController.cs

#LineLine coverage
 1using DCL.Social.Chat;
 2using System;
 3
 4namespace DCL.Social.Chat
 5{
 6    public class ChannelJoinErrorWindowController : IDisposable
 7    {
 8        private readonly IChannelJoinErrorWindowView view;
 9        private readonly IChatController chatController;
 10        private readonly DataStore dataStore;
 11        private string currentChannelId;
 12
 313        public ChannelJoinErrorWindowController(IChannelJoinErrorWindowView view,
 14            IChatController chatController,
 15            DataStore dataStore)
 16        {
 317            this.view = view;
 318            this.chatController = chatController;
 319            view.Hide();
 320            view.OnClose += Close;
 321            view.OnRetry += Retry;
 322            this.dataStore = dataStore;
 323            dataStore.channels.joinChannelError.OnChange += Show;
 324        }
 25
 26        public void Dispose()
 27        {
 028            dataStore.channels.joinChannelError.OnChange -= Show;
 29
 030            if (view != null)
 31            {
 032                view.OnClose -= Close;
 033                view.OnRetry -= Retry;
 034                view.Dispose();
 35            }
 036        }
 37
 38        private void Show(string currentChannelId, string previousChannelId)
 39        {
 540            if (string.IsNullOrEmpty(currentChannelId)) return;
 541            this.currentChannelId = currentChannelId;
 542            var channel = chatController.GetAllocatedChannel(currentChannelId);
 543            view.Show(channel?.Name ?? currentChannelId);
 544        }
 45
 246        private void Close() => view.Hide();
 47
 48        private void Retry()
 49        {
 150            chatController.JoinOrCreateChannel(currentChannelId);
 151            Close();
 152        }
 53    }
 54}