< Summary

Class:FriendRequestEntry
Assembly:FriendsHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/FriendsHUD/Scripts/Entries/FriendRequestEntry.cs
Covered lines:26
Uncovered lines:5
Coverable lines:31
Total lines:67
Line coverage:83.8% (26 of 31)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%110100%
Populate(...)0%110100%
Populate(...)0%6200%
SetReceived(...)0%220100%
PopulateReceived()0%110100%
PopulateSent()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/FriendsHUD/Scripts/Entries/FriendRequestEntry.cs

#LineLine coverage
 1using UnityEngine;
 2using UnityEngine.UI;
 3
 4public class FriendRequestEntry : FriendEntryBase
 5{
 6    [SerializeField] internal Button acceptButton;
 7    [SerializeField] internal Button rejectButton;
 8    [SerializeField] internal Button cancelButton;
 9
 010    public bool isReceived { get; private set; }
 11
 12    public event System.Action<FriendRequestEntry> OnAccepted;
 13    public event System.Action<FriendRequestEntry> OnRejected;
 14    public event System.Action<FriendRequestEntry> OnCancelled;
 15
 16    public override void Awake()
 17    {
 1518        base.Awake();
 19
 1520        acceptButton.onClick.RemoveAllListeners();
 1521        rejectButton.onClick.RemoveAllListeners();
 1522        cancelButton.onClick.RemoveAllListeners();
 1623        acceptButton.onClick.AddListener(() => OnAccepted?.Invoke(this));
 1624        rejectButton.onClick.AddListener(() => OnRejected?.Invoke(this));
 1625        cancelButton.onClick.AddListener(() => OnCancelled?.Invoke(this));
 1526    }
 27
 28    public void Populate(FriendRequestEntryModel model)
 29    {
 1130        base.Populate(model);
 1131        SetReceived(model.isReceived);
 1132    }
 33
 34    public override void Populate(FriendEntryModel model)
 35    {
 036        base.Populate(model);
 37
 038        if (model is FriendRequestEntryModel requestModel)
 039            SetReceived(requestModel.isReceived);
 040    }
 41
 42    private void SetReceived(bool value)
 43    {
 1144        isReceived = value;
 45
 1146        if (isReceived)
 447            PopulateReceived();
 48        else
 749            PopulateSent();
 750    }
 51
 52    private void PopulateReceived()
 53    {
 454        isReceived = true;
 455        cancelButton.gameObject.SetActive(false);
 456        acceptButton.gameObject.SetActive(true);
 457        rejectButton.gameObject.SetActive(true);
 458    }
 59
 60    private void PopulateSent()
 61    {
 762        isReceived = false;
 763        cancelButton.gameObject.SetActive(true);
 764        acceptButton.gameObject.SetActive(false);
 765        rejectButton.gameObject.SetActive(false);
 766    }
 67}