using LiteCharms.Features.Models; using LiteCharms.Features.TechShop.Notifications; using LiteCharms.Features.TechShop.Notifications.Events; using static LiteCharms.Features.Extensions.Email; namespace LiteCharms.Features.TechShop.Tests; public class NotificationsFeatureTests(Fixture fixture, ITestOutputHelper output) : IClassFixture { private readonly NotificationService notificationService = fixture.Services.GetRequiredService(); [Fact] public async Task CreateNotificationCommand_ShouldSucceed() { Notifications.Models.CreateNotification request = new() { CorrelationId = Guid.CreateVersion7().ToString(), CorrelationIdType = CorrelationIdTypes.None, Direction = NotificationDirection.Outgoing, Platform = NotificationPlatforms.Email, Priority = Priorities.Medium, Sender = "xUnit Test", SenderAddress = "khwezi@mngoma.africa", Recipient = $"{ShopEmailFromName} [Test]", RecipientAddress = ShopEmailFromAddress, Subject = "Test Message", Message = "This is an automation test", IsHtml = false, IsInternal = true, }; var createResult = await notificationService.CreateNotificationAsync(request); Assert.True(createResult.IsSuccess); foreach (var error in createResult.Errors) output.WriteLine(error.Message); } [Fact] public async Task GetNotifications_ShouldReturn_AllNotifications() { DateRange range = new() { From = DateOnly.FromDateTime(new DateTime(2026, 04, 01, 0, 0, 0, DateTimeKind.Utc)), To = DateOnly.FromDateTime(DateTime.UtcNow), MaxRecords = 10 }; var getResult = await notificationService.GetNotificationsAsync(range); Assert.True(getResult.IsSuccess); foreach (var error in getResult.Errors) output.WriteLine(error.Message); } [Fact] public async Task ProcessEmailNotificationsEvent_ShouldSucceed() { var notification = ProcessEmailNotificationsEvent.Create(); await fixture.Mediator.Publish(notification); Assert.True(true); } }