< Summary

Information
Class: MyNet.UI.Notifications.Models.ClosableNotification
Assembly: MyNet.UI
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.UI/Notifications/Models/ClosableNotification.cs
Tag: 323_28699572109
Line coverage
66%
Covered lines: 2
Uncovered lines: 1
Coverable lines: 3
Total lines: 45
Line coverage: 66.6%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
CanCloseAsync()100%210%
RequestClose()50%22100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.UI/Notifications/Models/ClosableNotification.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="ClosableNotification.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System;
 8using System.Threading.Tasks;
 9
 10namespace MyNet.UI.Notifications.Models;
 11
 12/// <summary>
 13/// Represents a notification that can be closed by the user or programmatically.
 14/// </summary>
 15/// <remarks>
 16/// Initializes a new instance of the <see cref="ClosableNotification"/> class.
 17/// </remarks>
 18/// <param name="message">The message content.</param>
 19/// <param name="title">The title of the notification.</param>
 20/// <param name="severity">The severity of the notification.</param>
 21/// <param name="isClosable">Indicates whether the notification can be closed.</param>
 3322public class ClosableNotification(string message, string title, NotificationSeverity severity, bool isClosable = true) :
 23{
 24    /// <summary>
 25    /// Gets a value indicating whether the notification can be closed.
 26    /// </summary>
 27    public bool IsClosable { get; } = isClosable;
 28
 29    /// <summary>
 30    /// Event raised when a request to close the notification is made, either by the user or programmatically.
 31    /// </summary>
 32    public event EventHandler<CloseRequestedEventArgs>? CloseRequested;
 33
 34    /// <summary>
 35    /// Determines asynchronously whether the notification can be closed.
 36    /// </summary>
 37    /// <returns>A task that returns true if the notification can be closed; otherwise, false.</returns>
 038    public Task<bool> CanCloseAsync() => Task.FromResult(IsClosable);
 39
 40    /// <summary>
 41    /// Closes the notification and raises the <see cref="CloseRequested"/> event.
 42    /// </summary>
 643    public void RequestClose() => CloseRequested?.Invoke(this, new());
 44}
 45