50 lines
1.8 KiB
C#
50 lines
1.8 KiB
C#
using System;
|
|
using System.Windows;
|
|
using System.Windows.Media;
|
|
using Xunit;
|
|
using ytLive.Services;
|
|
|
|
namespace ytLive.Tests;
|
|
|
|
/// <summary>
|
|
/// TASK 24: the pure severity → request mapping behind the toast service.
|
|
/// Errors must never auto-expire (sticky until dismissed); the rest get short
|
|
/// lifetimes; everything routes to the in-window ToastArea.
|
|
/// </summary>
|
|
public class NotificationServiceTests
|
|
{
|
|
[Theory]
|
|
[InlineData(AppNotificationSeverity.Info, 4)]
|
|
[InlineData(AppNotificationSeverity.Success, 4)]
|
|
[InlineData(AppNotificationSeverity.Warning, 8)]
|
|
public void Transient_Severities_Expire_With_Scheduled_Lifetimes(AppNotificationSeverity severity, double expectedSeconds)
|
|
{
|
|
var request = NotificationService.BuildRequest("Title", "Body", severity);
|
|
|
|
Assert.Equal("ToastArea", request.AreaName);
|
|
Assert.NotNull(request.ExpirationTime);
|
|
Assert.Equal(TimeSpan.FromSeconds(expectedSeconds), request.ExpirationTime);
|
|
}
|
|
|
|
[Fact]
|
|
public void Errors_Never_Expire_And_Route_To_The_Toast_Area()
|
|
{
|
|
var request = NotificationService.BuildRequest("Title", "Body", AppNotificationSeverity.Error);
|
|
|
|
Assert.Equal("ToastArea", request.AreaName);
|
|
Assert.Equal(TimeSpan.MaxValue, request.ExpirationTime);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(AppNotificationSeverity.Info, "#3a3b52")]
|
|
[InlineData(AppNotificationSeverity.Success, "#1d5c38")]
|
|
[InlineData(AppNotificationSeverity.Warning, "#b8860b")]
|
|
[InlineData(AppNotificationSeverity.Error, "#8f1f1f")]
|
|
public void Severities_Map_To_Dark_Card_Tints(AppNotificationSeverity severity, string expectedHex)
|
|
{
|
|
var request = NotificationService.BuildRequest("Title", "Body", severity);
|
|
|
|
Assert.Equal(expectedHex.ToLowerInvariant()[^6..], request.BackgroundColor!.Value.ToHex().ToLowerInvariant()[^6..]);
|
|
}
|
|
}
|