< Summary

Class:DCL.Social.Chat.PrivateChatHUDView
Assembly:PrivateChatWindowHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/PrivateChatWindow/PrivateChatHUDView.cs
Covered lines:4
Uncovered lines:15
Coverable lines:19
Total lines:43
Line coverage:21% (4 of 19)
Covered branches:0
Total branches:0
Covered methods:2
Total methods:5
Method coverage:40% (2 of 5)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
PrivateChatHUDView()0%110100%
Awake()0%110100%
SetEntry(...)0%2100%
ClearAllEntries()0%2100%
AddSeparatorEntryIfNeeded(...)0%6200%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/PrivateChatWindow/PrivateChatHUDView.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using UnityEngine;
 4
 5namespace DCL.Social.Chat
 6{
 7    public class PrivateChatHUDView : ChatHUDView
 8    {
 9        [SerializeField] private PoolPrivateChatEntryFactory chatEntryFactory;
 10
 1511        private readonly Dictionary<string, DateSeparatorEntry> dateSeparators = new ();
 12
 13        public override void Awake()
 14        {
 1415            base.Awake();
 1416            ChatEntryFactory = chatEntryFactory;
 1417        }
 18
 19        public override void SetEntry(ChatEntryModel model, bool setScrollPositionToBottom = false)
 20        {
 021            AddSeparatorEntryIfNeeded(model);
 022            base.SetEntry(model, setScrollPositionToBottom);
 023        }
 24
 25        public override void ClearAllEntries()
 26        {
 027            base.ClearAllEntries();
 028            dateSeparators.Clear();
 029        }
 30
 31        private void AddSeparatorEntryIfNeeded(ChatEntryModel chatEntryModel)
 32        {
 033            var entryDateTime = DateTimeOffset.FromUnixTimeMilliseconds((long) chatEntryModel.timestamp).Date;
 034            var separatorId = entryDateTime.Ticks.ToString();
 035            if (dateSeparators.ContainsKey(separatorId)) return;
 036            var dateSeparatorEntry = chatEntryFactory.CreateDateSeparator();
 037            Dock(dateSeparatorEntry);
 038            Populate(dateSeparatorEntry, chatEntryModel);
 039            dateSeparators[separatorId] = dateSeparatorEntry;
 040            SetEntry(separatorId, dateSeparatorEntry);
 041        }
 42    }
 43}