< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
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    /// Set the tag text.
 9    /// </summary>
 10    /// <param name="newText">New text.</param>
 11    void SetText(string newText);
 12
 13    /// <summary>
 14    /// Set the tag icon.
 15    /// </summary>
 16    /// <param name="newIcon">New Icon. Null for hide the icon.</param>
 17    void SetIcon(Sprite newIcon);
 18}
 19
 20public class TagComponentView : BaseComponentView, ITagComponentView, IComponentModelConfig<TagComponentModel>
 21{
 22    [Header("Prefab References")]
 23    [SerializeField] internal Image icon;
 24    [SerializeField] internal TMP_Text text;
 25
 26    [Header("Configuration")]
 27    [SerializeField] internal TagComponentModel model;
 28
 29    public void Configure(TagComponentModel newModel)
 30    {
 131        model = newModel;
 132        RefreshControl();
 133    }
 34
 35    public override void RefreshControl()
 36    {
 137        if (model == null)
 038            return;
 39
 140        SetText(model.text);
 141        SetIcon(model.icon);
 142    }
 43
 44    public void SetText(string newText)
 45    {
 3146        model.text = newText;
 47
 3148        if (text == null)
 049            return;
 50
 3151        text.text = newText;
 3152    }
 53
 54    public void SetIcon(Sprite newIcon)
 55    {
 356        model.icon = newIcon;
 57
 358        if (icon == null)
 059            return;
 60
 361        icon.enabled = newIcon != null;
 362        icon.sprite = newIcon;
 363    }
 64}