< Summary

Class:DateSeparatorEntry
Assembly:ChatHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/ChatWidgetHUD/DateSeparatorEntry.cs
Covered lines:7
Uncovered lines:3
Coverable lines:10
Total lines:46
Line coverage:70% (7 of 10)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Populate(...)0%110100%
GetDateFormat(...)0%4.594066.67%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/ChatWidgetHUD/DateSeparatorEntry.cs

#LineLine coverage
 1using System;
 2using TMPro;
 3using UnityEngine;
 4
 5/// <summary>
 6/// Special type of entry to be used as date separator in chat conversations.
 7/// </summary>
 8public class DateSeparatorEntry : MonoBehaviour
 9{
 10    public struct Model
 11    {
 12        public DateTime date;
 13    }
 14
 015    public Model model { get; private set; }
 16
 17    [SerializeField] internal TextMeshProUGUI title;
 18
 19    /// <summary>
 20    /// Configures the separator entry with the date information.
 21    /// </summary>
 22    /// <param name="dateSeparatorModel">DateSeparatorEntry.Model</param>
 23    public void Populate(Model dateSeparatorModel)
 24    {
 325        model = dateSeparatorModel;
 326        title.text = GetDateFormat(dateSeparatorModel.date);
 327    }
 28
 29    private string GetDateFormat(DateTime date)
 30    {
 331        string result = string.Empty;
 32
 333        if (date.Year == DateTime.Now.Year &&
 34            date.Month == DateTime.Now.Month &&
 35            date.Day == DateTime.Now.Day)
 36        {
 037            result = "Today";
 038        }
 39        else
 40        {
 341            result = date.ToLongDateString();
 42        }
 43
 344        return result;
 45    }
 46}