< Summary

Class:PrivateChatHUDView
Assembly:PrivateChatWindowHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/PrivateChatWindow/PrivateChatHUDView.cs
Covered lines:1
Uncovered lines:14
Coverable lines:15
Total lines:34
Line coverage:6.6% (1 of 15)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
PrivateChatHUDView()0%110100%
AddEntry(...)0%2100%
AddSeparatorEntryIfNeeded(...)0%6200%
GetDateTimeFromUnixTimestampMilliseconds(...)0%2100%

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
 5public class PrivateChatHUDView : ChatHUDView
 6{
 7    [SerializeField] private DateSeparatorEntry separatorEntryPrefab;
 8
 179    private readonly Dictionary<string, DateSeparatorEntry> dateSeparators = new Dictionary<string, DateSeparatorEntry>(
 10
 11    public override void AddEntry(ChatEntryModel model, bool setScrollPositionToBottom = false)
 12    {
 013        AddSeparatorEntryIfNeeded(model);
 014        base.AddEntry(model, setScrollPositionToBottom);
 015    }
 16
 17    private void AddSeparatorEntryIfNeeded(ChatEntryModel chatEntryModel)
 18    {
 019        var entryDateTime = GetDateTimeFromUnixTimestampMilliseconds(chatEntryModel.timestamp).Date;
 020        var separatorId = $"{entryDateTime.Ticks}";
 021        if (dateSeparators.ContainsKey(separatorId)) return;
 022        var dateSeparatorEntry = Instantiate(separatorEntryPrefab, chatEntriesContainer);
 023        dateSeparatorEntry.Populate(chatEntryModel);
 024        dateSeparatorEntry.SetFadeout(IsFadeoutModeEnabled);
 025        dateSeparators[separatorId] = dateSeparatorEntry;
 026        SetEntry(separatorId, dateSeparatorEntry);
 027    }
 28
 29    private DateTime GetDateTimeFromUnixTimestampMilliseconds(ulong milliseconds)
 30    {
 031        DateTime result = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 032        return result.AddMilliseconds(milliseconds);
 33    }
 34}