< Summary

Class:PublicChannelEntry
Assembly:WorldChatWindowHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/WorldChatWindowHUD/PublicChannelEntry.cs
Covered lines:14
Uncovered lines:4
Coverable lines:18
Total lines:62
Line coverage:77.7% (14 of 18)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Create()0%110100%
Awake()0%110100%
Initialize(...)0%2100%
Configure(...)0%110100%
RefreshControl()0%110100%
PublicChannelEntryModel(...)0%110100%

File(s)

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

#LineLine coverage
 1using System;
 2using TMPro;
 3using UnityEngine;
 4using UnityEngine.UI;
 5
 6public class PublicChannelEntry : BaseComponentView, IComponentModelConfig
 7{
 8    [SerializeField] internal Button openChatButton;
 9    [SerializeField] internal TMP_Text nameLabel;
 10    [SerializeField] internal PublicChannelEntryModel model;
 11    [SerializeField] internal UnreadNotificationBadge unreadNotifications;
 12
 13    private IChatController chatController;
 14    private ILastReadMessagesService lastReadMessagesService;
 15
 016    public PublicChannelEntryModel Model => model;
 17
 18    public event Action<PublicChannelEntry> OnOpenChat;
 19
 20    public static PublicChannelEntry Create()
 21    {
 222        return Instantiate(Resources.Load<PublicChannelEntry>("SocialBarV1/PublicChannelElement"));
 23    }
 24
 25    public override void Awake()
 26    {
 2127        base.Awake();
 2328        openChatButton.onClick.AddListener(() => OnOpenChat?.Invoke(this));
 2129    }
 30
 31    public void Initialize(IChatController chatController,
 32        ILastReadMessagesService lastReadMessagesService)
 33    {
 034        this.chatController = chatController;
 035        this.lastReadMessagesService = lastReadMessagesService;
 036    }
 37
 38    public void Configure(BaseComponentModel newModel)
 39    {
 1540        model = (PublicChannelEntryModel) newModel;
 1541        RefreshControl();
 1542    }
 43
 44    public override void RefreshControl()
 45    {
 1546        nameLabel.text = $"#{model.name}";
 1547        unreadNotifications.Initialize(chatController, model.channelId, lastReadMessagesService);
 1548    }
 49
 50    [Serializable]
 51    public class PublicChannelEntryModel : BaseComponentModel
 52    {
 53        public string channelId;
 54        public string name;
 55
 1556        public PublicChannelEntryModel(string channelId, string name)
 57        {
 1558            this.channelId = channelId;
 1559            this.name = name;
 1560        }
 61    }
 62}