< 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    {
 1718        base.Awake();
 19
 1720        acceptButton.onClick.RemoveAllListeners();
 1721        rejectButton.onClick.RemoveAllListeners();
 1722        cancelButton.onClick.RemoveAllListeners();
 1823        acceptButton.onClick.AddListener(() => OnAccepted?.Invoke(this));
 1824        rejectButton.onClick.AddListener(() => OnRejected?.Invoke(this));
 1825        cancelButton.onClick.AddListener(() => OnCancelled?.Invoke(this));
 1726    }
 27
 28    public void Populate(FriendRequestEntryModel model)
 29    {
 1230        base.Populate(model);
 1231        SetReceived(model.isReceived);
 1232    }
 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    {
 1244        isReceived = value;
 45
 1246        if (isReceived)
 547            PopulateReceived();
 48        else
 749            PopulateSent();
 750    }
 51
 52    private void PopulateReceived()
 53    {
 554        isReceived = true;
 555        cancelButton.gameObject.SetActive(false);
 556        acceptButton.gameObject.SetActive(true);
 557        rejectButton.gameObject.SetActive(true);
 558    }
 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}