< Summary

Class:TransactionListHUDView
Assembly:TransactionHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/TransactionHUD/TransactionListHUDView.cs
Covered lines:13
Uncovered lines:6
Coverable lines:19
Total lines:56
Line coverage:68.4% (13 of 19)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Create()0%110100%
Initialize()0%110100%
ShowTransaction(...)0%220100%
ShowTransaction(...)0%2.032080%
OnTransactionAccepted(...)0%6200%
OnTransactionRejected(...)0%6200%
SetActive(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/TransactionHUD/TransactionListHUDView.cs

#LineLine coverage
 1using System;
 2using DCL.TransactionHUDModel;
 3using UnityEngine;
 4
 5public class TransactionListHUDView : MonoBehaviour
 6{
 7    [SerializeField]
 8    private RectTransform transactionPanel;
 9
 10    public event Action<ITransactionHUD> OnTransactionAcceptedEvent;
 11    public event Action<ITransactionHUD> OnTransactionRejectedEvent;
 12
 13    private const string VIEW_PATH = "TransactionListHUD";
 14    private const string VIEW_CHILD_PATH = "TransactionHUD";
 15    private const string VIEW_OBJECT_NAME = "_TransactionListHUD";
 16
 17    internal static TransactionListHUDView Create()
 18    {
 319        TransactionListHUDView view = Instantiate(Resources.Load<TransactionListHUDView>(VIEW_PATH));
 320        view.Initialize();
 321        return view;
 22    }
 23
 624    private void Initialize() { gameObject.name = VIEW_OBJECT_NAME; }
 25
 26    public void ShowTransaction(ITransactionHUD transaction, Model model = null)
 27    {
 428        transaction.OnTransactionAccepted += OnTransactionAccepted;
 429        transaction.OnTransactionRejected += OnTransactionRejected;
 30
 431        if (model != null)
 432            transaction.Show(model);
 433    }
 34
 35    public TransactionHUD ShowTransaction(Model transactionModel)
 36    {
 437        if (transactionModel == null)
 038            return null;
 39
 440        TransactionHUD transactionHUD = Instantiate(Resources.Load<TransactionHUD>(VIEW_CHILD_PATH), transactionPanel);
 441        ShowTransaction(transactionHUD, transactionModel);
 442        return transactionHUD;
 43    }
 44
 45    private void OnTransactionAccepted(ITransactionHUD transaction)
 46    {
 047        OnTransactionAcceptedEvent?.Invoke(transaction);
 048    }
 49
 50    private void OnTransactionRejected(ITransactionHUD transaction)
 51    {
 052        OnTransactionRejectedEvent?.Invoke(transaction);
 053    }
 54
 055    public void SetActive(bool active) { gameObject.SetActive(active); }
 56}