< 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:49
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 UnityEngine;
 2
 3public class NotificationHUDView : MonoBehaviour
 4{
 5    public NotificationFactory notificationFactory;
 6
 7    [SerializeField]
 8    private RectTransform notificationPanel;
 9
 10    public event System.Action<Notification> OnNotificationDismissedEvent;
 11
 12    private const string VIEW_PATH = "NotificationHUD";
 13    private const string VIEW_OBJECT_NAME = "_NotificationHUD";
 14
 15    internal static NotificationHUDView Create()
 16    {
 1617        NotificationHUDView view = Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<NotificationHUDView>(
 1618        view.Initialize();
 1619        return view;
 20    }
 21
 3222    private void Initialize() { gameObject.name = VIEW_OBJECT_NAME; }
 23
 24    public void ShowNotification(Notification notification, Notification.Model model = null)
 25    {
 626        if (notification == null)
 027            return;
 28
 629        notification.OnNotificationDismissed += OnNotificationDismissed;
 30
 631        if (model != null)
 632            notification.Show(model);
 633    }
 34
 35    public Notification ShowNotification(Notification.Model notificationModel)
 36    {
 437        if (notificationModel == null)
 038            return null;
 39
 440        Notification notification = notificationFactory.CreateNotificationFromType(notificationModel.type, notificationP
 441        notificationModel.destroyOnFinish = true;
 442        ShowNotification(notification, notificationModel);
 443        return notification;
 44    }
 45
 246    private void OnNotificationDismissed(Notification notification) { OnNotificationDismissedEvent?.Invoke(notification)
 47
 248    public void SetActive(bool active) { gameObject.SetActive(active); }
 49}