Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7743c3178e | |||
| da141311ff | |||
| ab3d8e6e9a | |||
| 97bde73777 |
@@ -1,4 +1,5 @@
|
|||||||
using LiteCharms.Features.Shop.Notifications;
|
using LiteCharms.Features.Models;
|
||||||
|
using LiteCharms.Features.Shop.Notifications;
|
||||||
using LiteCharms.Features.Shop.Notifications.Events;
|
using LiteCharms.Features.Shop.Notifications.Events;
|
||||||
|
|
||||||
namespace LiteCharms.Features.Tests;
|
namespace LiteCharms.Features.Tests;
|
||||||
@@ -34,6 +35,23 @@ public class NotificationsFeatureTests(CommonFixture fixture, ITestOutputHelper
|
|||||||
foreach (var error in createResult.Errors) output.WriteLine(error.Message);
|
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]
|
[Fact]
|
||||||
public async Task ProcessEmailNotificationsEvent_ShouldSucceed()
|
public async Task ProcessEmailNotificationsEvent_ShouldSucceed()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ public class NotificationService(IDbContextFactory<ShopDbContext> contextFactory
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var fromDate = range.From.ToDateTime(TimeOnly.MinValue);
|
var fromDate = range.From.ToDateTime(TimeOnly.MinValue, DateTimeKind.Utc);
|
||||||
var toDate = range.To.ToDateTime(TimeOnly.MaxValue);
|
var toDate = range.To.ToDateTime(TimeOnly.MaxValue, DateTimeKind.Utc);
|
||||||
|
|
||||||
using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
||||||
|
|
||||||
@@ -96,12 +96,9 @@ public class NotificationService(IDbContextFactory<ShopDbContext> contextFactory
|
|||||||
return Result.Fail(new Error($"Notification with id {request.NotificationId} not found."));
|
return Result.Fail(new Error($"Notification with id {request.NotificationId} not found."));
|
||||||
|
|
||||||
notification.Processed = request.Processed;
|
notification.Processed = request.Processed;
|
||||||
|
notification.UpdatedAt = DateTime.UtcNow;
|
||||||
if (request.HasError)
|
notification.HasError = request.HasError;
|
||||||
{
|
notification.Errors = request.Errors;
|
||||||
notification.HasError = request.HasError;
|
|
||||||
notification.Errors = request.Errors;
|
|
||||||
}
|
|
||||||
|
|
||||||
return await context.SaveChangesAsync(cancellationToken) > 0
|
return await context.SaveChangesAsync(cancellationToken) > 0
|
||||||
? Result.Ok()
|
? Result.Ok()
|
||||||
|
|||||||
Reference in New Issue
Block a user