< Summary

Class:NotificationHUDView
Assembly:NotificationHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/NotificationHUD/NotificationHUDView.cs
Covered lines:16
Uncovered lines:2
Coverable lines:18
Total lines:51
Line coverage:88.8% (16 of 18)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Create()0%110100%
Initialize()0%110100%
ShowNotification(...)0%3.043083.33%
ShowNotification(...)0%2.022083.33%
OnNotificationDismissed(...)0%220100%
SetActive(...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/NotificationHUD/NotificationHUDView.cs

#LineLine coverage
 1using System;
 2using DCL.NotificationModel;
 3using UnityEngine;
 4
 5public class NotificationHUDView : MonoBehaviour
 6{
 7    public NotificationFactory notificationFactory;
 8
 9    [SerializeField]
 10    private RectTransform notificationPanel;
 11
 12    public event Action<INotification> OnNotificationDismissedEvent;
 13
 14    private const string VIEW_PATH = "NotificationHUD";
 15    private const string VIEW_OBJECT_NAME = "_NotificationHUD";
 16
 17    internal static NotificationHUDView Create()
 18    {
 1619        NotificationHUDView view = Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<NotificationHUDView>(
 1620        view.Initialize();
 1621        return view;
 22    }
 23
 3224    private void Initialize() { gameObject.name = VIEW_OBJECT_NAME; }
 25
 26    public void ShowNotification(INotification notification, Model model = null)
 27    {
 628        if (notification == null)
 029            return;
 30
 631        notification.OnNotificationDismissed += OnNotificationDismissed;
 32
 633        if (model != null)
 634            notification.Show(model);
 635    }
 36
 37    public Notification ShowNotification(Model notificationModel)
 38    {
 439        if (notificationModel == null)
 040            return null;
 41
 442        Notification notification = notificationFactory.CreateNotificationFromType(notificationModel.type, notificationP
 443        notificationModel.destroyOnFinish = true;
 444        ShowNotification(notification, notificationModel);
 445        return notification;
 46    }
 47
 248    private void OnNotificationDismissed(INotification notification) { OnNotificationDismissedEvent?.Invoke(notification
 49
 250    public void SetActive(bool active) { gameObject.SetActive(active); }
 51}