Files
hrynco-notification-service/HrynCo.NotificationService.Web.IntegrationTests/PushDeliveryRepositoryTests.cs
T
agrynco 1631786ce2 feat(push): add service-owned firebase channels and delivery
Add push contracts, provider delivery and channel diagnostics. Link email channels to services and document migration and validation.

Ref: IT-1074
2026-10-24 12:31:35 +03:00

35 lines
1.7 KiB
C#

namespace HrynCo.NotificationService.Web.IntegrationTests;
using HrynCo.NotificationService.DAL.Abstract.Push;
using HrynCo.NotificationService.DAL.EF;
using Microsoft.Extensions.DependencyInjection;
public sealed class PushDeliveryRepositoryTests(TemplateDatabaseFixture fixture) : IClassFixture<TemplateDatabaseFixture>
{
[Fact]
public async Task RedeliveryReplaysOutcomeAndFailedProviderCallCanRetry()
{
var connection = await fixture.CreateDatabaseAsync();
using var provider = new ServiceCollection().AddNotificationDataAccess(connection).BuildServiceProvider();
var id = Guid.NewGuid();
using (var first = provider.CreateScope())
{
var repository = first.ServiceProvider.GetRequiredService<IPushDeliveryRepository>();
await Assert.ThrowsAsync<InvalidOperationException>(() => repository.DeliverOnceAsync(id, "Invemory",
_ => throw new InvalidOperationException("transient"), default));
}
using (var retry = provider.CreateScope())
{
var repository = retry.ServiceProvider.GetRequiredService<IPushDeliveryRepository>();
var result = await repository.DeliverOnceAsync(id, "Invemory",
_ => Task.FromResult(new PushDeliveryOutcome("unregistered", true)), default);
Assert.True(result.InvalidRegistration);
}
using var redelivery = provider.CreateScope();
var saved = await redelivery.ServiceProvider.GetRequiredService<IPushDeliveryRepository>()
.DeliverOnceAsync(id, "Invemory", _ => throw new Exception("must not send twice"), default);
Assert.Equal("unregistered", saved.Error);
Assert.True(saved.InvalidRegistration);
}
}