Failing unit + acceptance tests for the Event Subscriber's NotificationProjector: a zaken/zaak/create notification yields one INGEDIEND projection row, duplicate deliveries collapse to one row, non-zaak/non-create notifications are ignored, and a rebuild repopulates the projection from the durable notification log (PRD §8.4). The projector is a no-op stub so the tests compile and fail on the assertions; the implementation follows in the green commit. The notification log doubles as the idempotency guard and rebuild source so a rebuild needs no OpenZaak access (§8.1). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
38 lines
1.4 KiB
C#
38 lines
1.4 KiB
C#
using EventSubscriber.Application;
|
|
|
|
namespace EventSubscriber.Tests;
|
|
|
|
/// <summary>In-memory stand-ins for the projection store and notification log, so the
|
|
/// projector's behaviour is exercised without Postgres (hand-written stubs, the repo's
|
|
/// convention — no mocking library).</summary>
|
|
internal sealed class InMemoryNotificationLog : INotificationLog
|
|
{
|
|
private readonly Dictionary<string, RecordedNotification> _byKey = [];
|
|
|
|
public Task<bool> TryRecordAsync(RecordedNotification notification, CancellationToken ct = default)
|
|
=> Task.FromResult(_byKey.TryAdd(notification.Key, notification));
|
|
|
|
public Task<IReadOnlyList<RecordedNotification>> AllAsync(CancellationToken ct = default)
|
|
=> Task.FromResult<IReadOnlyList<RecordedNotification>>([.. _byKey.Values]);
|
|
}
|
|
|
|
internal sealed class InMemoryProjectionStore : IProjectionStore
|
|
{
|
|
private readonly Dictionary<string, RegisterEntry> _byId = [];
|
|
|
|
public Task UpsertAsync(RegisterEntry entry, CancellationToken ct = default)
|
|
{
|
|
_byId[entry.Id] = entry;
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
public Task ClearAsync(CancellationToken ct = default)
|
|
{
|
|
_byId.Clear();
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
public Task<IReadOnlyList<RegisterEntry>> AllAsync(CancellationToken ct = default)
|
|
=> Task.FromResult<IReadOnlyList<RegisterEntry>>([.. _byId.Values]);
|
|
}
|