< Summary

Class:TransactionHUDController
Assembly:TransactionHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/TransactionHUD/TransactionHUDController.cs
Covered lines:18
Uncovered lines:16
Coverable lines:34
Total lines:74
Line coverage:52.9% (18 of 34)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Model()0%110100%
TransactionHUDController()0%110100%
TransactionHUDController(...)0%2100%
Initialize()0%110100%
ShowTransaction(...)0%2100%
ShowTransaction(...)0%110100%
OnTransactionAccepted(...)0%2100%
OnTransactionRejected(...)0%2100%
SetActive(...)0%2100%
Dispose()0%330100%
SetVisibility(...)0%2100%

File(s)

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

#LineLine coverage
 1using System.Collections.Generic;
 2using DCL;
 3using UnityEngine;
 4
 5public class TransactionHUDController : IHUD, ITransactionHUDController
 6{
 7    [System.Serializable]
 8    public class Model
 9    {
 310        public List<ITransactionHUD> transactions = new List<ITransactionHUD>();
 11    }
 12
 013    public TransactionListHUDView view { get; private set; }
 014    public Model model { get; private set; }
 615    public TransactionHUDController() : this(new Model()) { }
 16
 17    private TransactionBridge transactionBridge;
 18
 019    public TransactionHUDController(Model model)
 20    {
 021        this.model = model;
 022    }
 23
 24    public void Initialize()
 25    {
 326        view = TransactionListHUDView.Create();
 327        view.OnTransactionAcceptedEvent += OnTransactionAccepted;
 328        view.OnTransactionRejectedEvent += OnTransactionRejected;
 29
 330        transactionBridge = SceneReferences.i.bridgeGameObject.AddComponent<TransactionBridge>();
 331        transactionBridge.transactionController = this;
 332    }
 33
 34    public void ShowTransaction(ITransactionHUD transaction)
 35    {
 036        model.transactions.Add(transaction);
 037        view.ShowTransaction(transaction, transaction.model);
 038    }
 39    public void ShowTransaction(DCL.TransactionHUDModel.Model model)
 40    {
 441        var transaction = view.ShowTransaction(model);
 442        this.model.transactions.Add(transaction);
 443    }
 44
 45    private void OnTransactionAccepted(ITransactionHUD transaction)
 46    {
 047        DCL.Interface.WebInterface.Web3UseResponse(transaction.model.id, true);
 048        model.transactions.Remove(transaction);
 049    }
 50    private void OnTransactionRejected(ITransactionHUD transaction)
 51    {
 052        DCL.Interface.WebInterface.Web3UseResponse(transaction.model.id, false);
 053        model.transactions.Remove(transaction);
 054    }
 55
 056    public void SetActive(bool active) { view.SetActive(active); }
 57
 58    public void Dispose()
 59    {
 360        if (transactionBridge != null)
 61        {
 362            Object.Destroy(transactionBridge);
 63        }
 364        if (view != null)
 65        {
 366            Object.Destroy(view.gameObject);
 67        }
 68
 369        view.OnTransactionAcceptedEvent -= OnTransactionAccepted;
 370        view.OnTransactionRejectedEvent -= OnTransactionRejected;
 371    }
 72
 073    public void SetVisibility(bool visible) { SetActive(visible); }
 74}