< Summary

Class:TagComponentView
Assembly:UIComponents
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/UIComponents/Scripts/Components/Tag/TagComponentView.cs
Covered lines:18
Uncovered lines:3
Coverable lines:21
Total lines:76
Line coverage:85.7% (18 of 21)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
PostInitialization()0%110100%
Configure(...)0%110100%
RefreshControl()0%2.032080%
SetText(...)0%2.032080%
SetIcon(...)0%2.022083.33%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/UIComponents/Scripts/Components/Tag/TagComponentView.cs

#LineLine coverage
 1using TMPro;
 2using UnityEngine;
 3using UnityEngine.UI;
 4
 5public interface ITagComponentView
 6{
 7    /// <summary>
 8    /// Fill the model and updates the tag with this data.
 9    /// </summary>
 10    /// <param name="model">Data to configure the tag.</param>
 11    void Configure(TagComponentModel model);
 12
 13    /// <summary>
 14    /// Set the tag text.
 15    /// </summary>
 16    /// <param name="newText">New text.</param>
 17    void SetText(string newText);
 18
 19    /// <summary>
 20    /// Set the tag icon.
 21    /// </summary>
 22    /// <param name="newIcon">New Icon. Null for hide the icon.</param>
 23    void SetIcon(Sprite newIcon);
 24}
 25
 26public class TagComponentView : BaseComponentView, ITagComponentView
 27{
 28    [Header("Prefab References")]
 29    [SerializeField] internal Image icon;
 30    [SerializeField] internal TMP_Text text;
 31
 32    [Header("Configuration")]
 33    [SerializeField] internal TagComponentModel model;
 34
 35    public override void PostInitialization()
 36    {
 37        ;
 1538        Configure(model);
 1539    }
 40
 41    public void Configure(TagComponentModel model)
 42    {
 1643        this.model = model;
 1644        RefreshControl();
 1645    }
 46
 47    public override void RefreshControl()
 48    {
 1749        if (model == null)
 050            return;
 51
 1752        SetText(model.text);
 1753        SetIcon(model.icon);
 1754    }
 55
 56    public void SetText(string newText)
 57    {
 1858        model.text = newText;
 59
 1860        if (text == null)
 061            return;
 62
 1863        text.text = newText;
 1864    }
 65
 66    public void SetIcon(Sprite newIcon)
 67    {
 1968        model.icon = newIcon;
 69
 1970        if (icon == null)
 071            return;
 72
 1973        icon.enabled = newIcon != null;
 1974        icon.sprite = newIcon;
 1975    }
 76}