test(domain): herregistratie inscription date + reminder-due rule (refs #18)
The Registration aggregate gains the herregistratie clock: Approve now records the inscription moment, from which the herregistratie deadline and a reminder-due rule are derived. Members are stubbed so the suite compiles and the new assertions fail; the green commit implements them. Approve's signature gains the inscription moment (callers now supply 'now' from an injected TimeProvider). refs #18
This commit is contained in:
@@ -15,6 +15,10 @@ builder.Services.AddSingleton(sp => sp.GetRequiredService<IConfiguration>()
|
|||||||
// The in-memory registration store is shared between the submit endpoint and the worker (ADR-0009).
|
// The in-memory registration store is shared between the submit endpoint and the worker (ADR-0009).
|
||||||
builder.Services.AddSingleton<IRegistrationStore, InMemoryRegistrationStore>();
|
builder.Services.AddSingleton<IRegistrationStore, InMemoryRegistrationStore>();
|
||||||
|
|
||||||
|
// The system clock, injected wherever a use case needs "now" (e.g. stamping the inscription moment
|
||||||
|
// on approval, S-17). Injected as TimeProvider so tests can substitute a fixed clock.
|
||||||
|
builder.Services.AddSingleton(TimeProvider.System);
|
||||||
|
|
||||||
// The Workflow Client is one type behind two ports (start side + worker side); both resolve to the
|
// The Workflow Client is one type behind two ports (start side + worker side); both resolve to the
|
||||||
// same HttpClient-backed implementation — the only code that talks to Flowable (§8.2).
|
// same HttpClient-backed implementation — the only code that talks to Flowable (§8.2).
|
||||||
builder.Services.AddHttpClient<FlowableWorkflowClient>();
|
builder.Services.AddHttpClient<FlowableWorkflowClient>();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public sealed record ApproveRegistrationCommand(RegistrationId RegistrationId);
|
|||||||
/// zaak status is the projection's source of truth (it flows back over NRC); the aggregate transition
|
/// zaak status is the projection's source of truth (it flows back over NRC); the aggregate transition
|
||||||
/// keeps the domain's own view consistent.
|
/// keeps the domain's own view consistent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class ApproveRegistration(IRegistrationStore store, IAclClient acl)
|
public sealed class ApproveRegistration(IRegistrationStore store, IAclClient acl, TimeProvider clock)
|
||||||
{
|
{
|
||||||
public async Task HandleAsync(ApproveRegistrationCommand command, CancellationToken ct = default)
|
public async Task HandleAsync(ApproveRegistrationCommand command, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
@@ -30,7 +30,7 @@ public sealed class ApproveRegistration(IRegistrationStore store, IAclClient acl
|
|||||||
$"Registration {command.RegistrationId} has no zaak yet; it cannot be approved.");
|
$"Registration {command.RegistrationId} has no zaak yet; it cannot be approved.");
|
||||||
|
|
||||||
await acl.ApproveZaakAsync(registration.ZaakUrl, ct);
|
await acl.ApproveZaakAsync(registration.ZaakUrl, ct);
|
||||||
registration.Approve();
|
registration.Approve(clock.GetUtcNow());
|
||||||
await store.SaveAsync(registration, ct);
|
await store.SaveAsync(registration, ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public sealed record BeoordeelRegistratieCommand(RegistrationId RegistrationId,
|
|||||||
/// decisions are idempotent — a repeated or redelivered decision that matches the current terminal
|
/// decisions are idempotent — a repeated or redelivered decision that matches the current terminal
|
||||||
/// state is a no-op, so the ACL is not called and the task not completed twice.
|
/// state is a no-op, so the ACL is not called and the task not completed twice.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class BeoordeelRegistratie(IRegistrationStore store, IAclClient acl, IUserTaskClient tasks)
|
public sealed class BeoordeelRegistratie(IRegistrationStore store, IAclClient acl, IUserTaskClient tasks, TimeProvider clock)
|
||||||
{
|
{
|
||||||
public async Task HandleAsync(BeoordeelRegistratieCommand command, CancellationToken ct = default)
|
public async Task HandleAsync(BeoordeelRegistratieCommand command, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
@@ -44,7 +44,7 @@ public sealed class BeoordeelRegistratie(IRegistrationStore store, IAclClient ac
|
|||||||
throw new InvalidOperationException(
|
throw new InvalidOperationException(
|
||||||
$"Registration {command.RegistrationId} has no zaak yet; it cannot be approved.");
|
$"Registration {command.RegistrationId} has no zaak yet; it cannot be approved.");
|
||||||
await acl.ApproveZaakAsync(registration.ZaakUrl, ct);
|
await acl.ApproveZaakAsync(registration.ZaakUrl, ct);
|
||||||
registration.Approve();
|
registration.Approve(clock.GetUtcNow());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BeoordelingsBesluit.Afwijzen:
|
case BeoordelingsBesluit.Afwijzen:
|
||||||
|
|||||||
@@ -92,11 +92,12 @@ public sealed class Registration
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Approve the registration — the behandelaar's decision to enter it in the register. Advances a
|
/// Approve the registration — the behandelaar's decision to enter it in the register. Advances a
|
||||||
/// submitted or in-behandeling registration to <see cref="RegistrationStatus.Ingeschreven"/>.
|
/// submitted or in-behandeling registration to <see cref="RegistrationStatus.Ingeschreven"/> and
|
||||||
/// Requires an opened zaak (the approval sets that zaak's status via the ACL); a registration that
|
/// records <paramref name="ingeschrevenOp"/> as the moment of inscription, which starts the
|
||||||
/// has already been decided cannot be approved again.
|
/// herregistratie clock (S-17). Requires an opened zaak (the approval sets that zaak's status via
|
||||||
|
/// the ACL); a registration that has already been decided cannot be approved again.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Approve()
|
public void Approve(DateTimeOffset ingeschrevenOp)
|
||||||
{
|
{
|
||||||
if (ZaakUrl is null)
|
if (ZaakUrl is null)
|
||||||
throw new InvalidOperationException(
|
throw new InvalidOperationException(
|
||||||
@@ -104,8 +105,40 @@ public sealed class Registration
|
|||||||
|
|
||||||
RequireOpenForDecision(nameof(Approve));
|
RequireOpenForDecision(nameof(Approve));
|
||||||
Status = RegistrationStatus.Ingeschreven;
|
Status = RegistrationStatus.Ingeschreven;
|
||||||
|
// RED stub: the inscription moment is not stored yet.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- Herregistratie (S-17) — RED stubs, implemented in the green commit ---------------------
|
||||||
|
|
||||||
|
/// <summary>How long a BIG inscription stays valid before herregistratie is required.</summary>
|
||||||
|
// ponytail: fixed 5-year term — a calibration knob, not a config surface. If a demo needs it
|
||||||
|
// per-catalogus, promote it to policy passed in from the beheer config (S-15).
|
||||||
|
public static readonly TimeSpan HerregistratieGeldigheid = TimeSpan.FromDays(365 * 5);
|
||||||
|
|
||||||
|
/// <summary>How long before the deadline the herregistratie reminder is sent (BIG: ~16 weeks).</summary>
|
||||||
|
// ponytail: fixed 16-week lead time — calibration knob; same promotion path as HerregistratieGeldigheid.
|
||||||
|
public static readonly TimeSpan Herinneringstermijn = TimeSpan.FromDays(16 * 7);
|
||||||
|
|
||||||
|
/// <summary>When the registration was entered in the register, once approved; the start of its
|
||||||
|
/// herregistratie clock. Null until it is <see cref="RegistrationStatus.Ingeschreven"/>.</summary>
|
||||||
|
public DateTimeOffset? IngeschrevenOp { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>The date by which herregistratie must happen: inscription + validity. Null until
|
||||||
|
/// inscribed.</summary>
|
||||||
|
public DateTimeOffset? HerregistratieVoor => null; // RED stub
|
||||||
|
|
||||||
|
/// <summary>Whether the herregistratie reminder has been sent for this inscription (S-17).</summary>
|
||||||
|
public bool HerregistratieReminderVerstuurd { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>Whether, as of <paramref name="asOf"/>, this registration is due a herregistratie
|
||||||
|
/// reminder: it is inscribed, the reminder window before its deadline has opened, and it has not
|
||||||
|
/// already been reminded.</summary>
|
||||||
|
public bool HerregistratieReminderDue(DateTimeOffset asOf) => false; // RED stub
|
||||||
|
|
||||||
|
/// <summary>Record that the herregistratie reminder has been sent. Idempotent — a re-sweep is a
|
||||||
|
/// no-op; only an inscribed registration can be reminded.</summary>
|
||||||
|
public void MarkHerregistratieReminderVerstuurd() { } // RED stub
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reject the registration — the behandelaar's decision not to enter it in the register. Advances a
|
/// Reject the registration — the behandelaar's decision not to enter it in the register. Advances a
|
||||||
/// submitted or in-behandeling registration to <see cref="RegistrationStatus.Afgewezen"/>. Unlike
|
/// submitted or in-behandeling registration to <see cref="RegistrationStatus.Afgewezen"/>. Unlike
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class ApproveRegistrationTests
|
|||||||
var acl = new FakeAclClient();
|
var acl = new FakeAclClient();
|
||||||
var registration = WithZaak();
|
var registration = WithZaak();
|
||||||
store.Seed(registration);
|
store.Seed(registration);
|
||||||
var handler = new ApproveRegistration(store, acl);
|
var handler = new ApproveRegistration(store, acl, TimeProvider.System);
|
||||||
|
|
||||||
await handler.HandleAsync(new ApproveRegistrationCommand(registration.Id));
|
await handler.HandleAsync(new ApproveRegistrationCommand(registration.Id));
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ public class ApproveRegistrationTests
|
|||||||
{
|
{
|
||||||
var store = new FakeRegistrationStore();
|
var store = new FakeRegistrationStore();
|
||||||
var acl = new FakeAclClient();
|
var acl = new FakeAclClient();
|
||||||
var handler = new ApproveRegistration(store, acl);
|
var handler = new ApproveRegistration(store, acl, TimeProvider.System);
|
||||||
|
|
||||||
await Assert.ThrowsAsync<ArgumentNullException>(() => handler.HandleAsync(null!));
|
await Assert.ThrowsAsync<ArgumentNullException>(() => handler.HandleAsync(null!));
|
||||||
Assert.Equal(0, acl.ApproveCallCount);
|
Assert.Equal(0, acl.ApproveCallCount);
|
||||||
@@ -47,7 +47,7 @@ public class ApproveRegistrationTests
|
|||||||
{
|
{
|
||||||
var store = new FakeRegistrationStore();
|
var store = new FakeRegistrationStore();
|
||||||
var acl = new FakeAclClient();
|
var acl = new FakeAclClient();
|
||||||
var handler = new ApproveRegistration(store, acl);
|
var handler = new ApproveRegistration(store, acl, TimeProvider.System);
|
||||||
|
|
||||||
var ex = await Assert.ThrowsAsync<InvalidOperationException>(
|
var ex = await Assert.ThrowsAsync<InvalidOperationException>(
|
||||||
() => handler.HandleAsync(new ApproveRegistrationCommand(RegistrationId.New())));
|
() => handler.HandleAsync(new ApproveRegistrationCommand(RegistrationId.New())));
|
||||||
@@ -62,7 +62,7 @@ public class ApproveRegistrationTests
|
|||||||
var acl = new FakeAclClient();
|
var acl = new FakeAclClient();
|
||||||
var registration = Registration.Submit("123456782"); // no zaak yet
|
var registration = Registration.Submit("123456782"); // no zaak yet
|
||||||
store.Seed(registration);
|
store.Seed(registration);
|
||||||
var handler = new ApproveRegistration(store, acl);
|
var handler = new ApproveRegistration(store, acl, TimeProvider.System);
|
||||||
|
|
||||||
var ex = await Assert.ThrowsAsync<InvalidOperationException>(
|
var ex = await Assert.ThrowsAsync<InvalidOperationException>(
|
||||||
() => handler.HandleAsync(new ApproveRegistrationCommand(registration.Id)));
|
() => handler.HandleAsync(new ApproveRegistrationCommand(registration.Id)));
|
||||||
@@ -77,7 +77,7 @@ public class ApproveRegistrationTests
|
|||||||
var acl = new FakeAclClient();
|
var acl = new FakeAclClient();
|
||||||
var registration = WithZaak();
|
var registration = WithZaak();
|
||||||
store.Seed(registration);
|
store.Seed(registration);
|
||||||
var handler = new ApproveRegistration(store, acl);
|
var handler = new ApproveRegistration(store, acl, TimeProvider.System);
|
||||||
|
|
||||||
await handler.HandleAsync(new ApproveRegistrationCommand(registration.Id));
|
await handler.HandleAsync(new ApproveRegistrationCommand(registration.Id));
|
||||||
await handler.HandleAsync(new ApproveRegistrationCommand(registration.Id));
|
await handler.HandleAsync(new ApproveRegistrationCommand(registration.Id));
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class BeoordeelRegistratieTests
|
|||||||
var registration = WithZaak();
|
var registration = WithZaak();
|
||||||
store.Seed(registration);
|
store.Seed(registration);
|
||||||
var tasks = TaskFor(registration);
|
var tasks = TaskFor(registration);
|
||||||
var handler = new BeoordeelRegistratie(store, acl, tasks);
|
var handler = new BeoordeelRegistratie(store, acl, tasks, TimeProvider.System);
|
||||||
|
|
||||||
await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Goedkeuren));
|
await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Goedkeuren));
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ public class BeoordeelRegistratieTests
|
|||||||
var registration = WithZaak();
|
var registration = WithZaak();
|
||||||
store.Seed(registration);
|
store.Seed(registration);
|
||||||
var tasks = TaskFor(registration);
|
var tasks = TaskFor(registration);
|
||||||
var handler = new BeoordeelRegistratie(store, acl, tasks);
|
var handler = new BeoordeelRegistratie(store, acl, tasks, TimeProvider.System);
|
||||||
|
|
||||||
await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Afwijzen));
|
await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Afwijzen));
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ public class BeoordeelRegistratieTests
|
|||||||
var registration = WithZaak();
|
var registration = WithZaak();
|
||||||
registration.TakeIntoBehandeling();
|
registration.TakeIntoBehandeling();
|
||||||
store.Seed(registration);
|
store.Seed(registration);
|
||||||
var handler = new BeoordeelRegistratie(store, acl, TaskFor(registration));
|
var handler = new BeoordeelRegistratie(store, acl, TaskFor(registration), TimeProvider.System);
|
||||||
|
|
||||||
await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Goedkeuren));
|
await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Goedkeuren));
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ public class BeoordeelRegistratieTests
|
|||||||
{
|
{
|
||||||
var store = new FakeRegistrationStore();
|
var store = new FakeRegistrationStore();
|
||||||
var acl = new FakeAclClient();
|
var acl = new FakeAclClient();
|
||||||
var handler = new BeoordeelRegistratie(store, acl, new FakeUserTaskClient([]));
|
var handler = new BeoordeelRegistratie(store, acl, new FakeUserTaskClient([]), TimeProvider.System);
|
||||||
|
|
||||||
await Assert.ThrowsAsync<ArgumentNullException>(() => handler.HandleAsync(null!));
|
await Assert.ThrowsAsync<ArgumentNullException>(() => handler.HandleAsync(null!));
|
||||||
Assert.Equal(0, acl.ApproveCallCount);
|
Assert.Equal(0, acl.ApproveCallCount);
|
||||||
@@ -93,7 +93,7 @@ public class BeoordeelRegistratieTests
|
|||||||
{
|
{
|
||||||
var store = new FakeRegistrationStore();
|
var store = new FakeRegistrationStore();
|
||||||
var acl = new FakeAclClient();
|
var acl = new FakeAclClient();
|
||||||
var handler = new BeoordeelRegistratie(store, acl, new FakeUserTaskClient([]));
|
var handler = new BeoordeelRegistratie(store, acl, new FakeUserTaskClient([]), TimeProvider.System);
|
||||||
|
|
||||||
var ex = await Assert.ThrowsAsync<InvalidOperationException>(() =>
|
var ex = await Assert.ThrowsAsync<InvalidOperationException>(() =>
|
||||||
handler.HandleAsync(new BeoordeelRegistratieCommand(RegistrationId.New(), BeoordelingsBesluit.Goedkeuren)));
|
handler.HandleAsync(new BeoordeelRegistratieCommand(RegistrationId.New(), BeoordelingsBesluit.Goedkeuren)));
|
||||||
@@ -108,7 +108,7 @@ public class BeoordeelRegistratieTests
|
|||||||
var acl = new FakeAclClient();
|
var acl = new FakeAclClient();
|
||||||
var registration = Registration.Submit("123456782"); // no zaak yet
|
var registration = Registration.Submit("123456782"); // no zaak yet
|
||||||
store.Seed(registration);
|
store.Seed(registration);
|
||||||
var handler = new BeoordeelRegistratie(store, acl, TaskFor(registration));
|
var handler = new BeoordeelRegistratie(store, acl, TaskFor(registration), TimeProvider.System);
|
||||||
|
|
||||||
var ex = await Assert.ThrowsAsync<InvalidOperationException>(() =>
|
var ex = await Assert.ThrowsAsync<InvalidOperationException>(() =>
|
||||||
handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Goedkeuren)));
|
handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Goedkeuren)));
|
||||||
@@ -123,7 +123,7 @@ public class BeoordeelRegistratieTests
|
|||||||
var acl = new FakeAclClient();
|
var acl = new FakeAclClient();
|
||||||
var registration = WithZaak();
|
var registration = WithZaak();
|
||||||
store.Seed(registration);
|
store.Seed(registration);
|
||||||
var handler = new BeoordeelRegistratie(store, acl, TaskFor(registration));
|
var handler = new BeoordeelRegistratie(store, acl, TaskFor(registration), TimeProvider.System);
|
||||||
|
|
||||||
await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Goedkeuren));
|
await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Goedkeuren));
|
||||||
await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Goedkeuren));
|
await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Goedkeuren));
|
||||||
@@ -139,7 +139,7 @@ public class BeoordeelRegistratieTests
|
|||||||
var acl = new FakeAclClient();
|
var acl = new FakeAclClient();
|
||||||
var registration = WithZaak();
|
var registration = WithZaak();
|
||||||
store.Seed(registration);
|
store.Seed(registration);
|
||||||
var handler = new BeoordeelRegistratie(store, acl, TaskFor(registration));
|
var handler = new BeoordeelRegistratie(store, acl, TaskFor(registration), TimeProvider.System);
|
||||||
|
|
||||||
await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Afwijzen));
|
await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Afwijzen));
|
||||||
await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Afwijzen));
|
await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Afwijzen));
|
||||||
@@ -158,7 +158,7 @@ public class BeoordeelRegistratieTests
|
|||||||
var registration = WithZaak();
|
var registration = WithZaak();
|
||||||
store.Seed(registration);
|
store.Seed(registration);
|
||||||
var tasks = new FakeUserTaskClient([]); // no open task for this registration
|
var tasks = new FakeUserTaskClient([]); // no open task for this registration
|
||||||
var handler = new BeoordeelRegistratie(store, acl, tasks);
|
var handler = new BeoordeelRegistratie(store, acl, tasks, TimeProvider.System);
|
||||||
|
|
||||||
await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Goedkeuren));
|
await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Goedkeuren));
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class InMemoryRegistrationStoreTests
|
|||||||
switch (transition)
|
switch (transition)
|
||||||
{
|
{
|
||||||
case nameof(Registration.Withdraw): registration.Withdraw(); break;
|
case nameof(Registration.Withdraw): registration.Withdraw(); break;
|
||||||
case nameof(Registration.Approve): registration.Approve(); break;
|
case nameof(Registration.Approve): registration.Approve(DateTimeOffset.UtcNow); break;
|
||||||
case nameof(Registration.Reject): registration.Reject(); break;
|
case nameof(Registration.Reject): registration.Reject(); break;
|
||||||
case nameof(Registration.Expire): registration.Expire(); break;
|
case nameof(Registration.Expire): registration.Expire(); break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
using Big.Domain;
|
||||||
|
|
||||||
|
namespace Big.Tests;
|
||||||
|
|
||||||
|
// S-17 (#18): a BIG inscription is valid for a fixed term; before it lapses the zorgprofessional must
|
||||||
|
// herregistreren. The aggregate records when it was inscribed, derives the herregistratie deadline, and
|
||||||
|
// answers whether a reminder is due as of a given moment — the single rule the Quartz sweep and the
|
||||||
|
// store query both build on. All arithmetic is against an explicit "now" so it is wall-clock-free.
|
||||||
|
public class RegistrationHerregistratieTests
|
||||||
|
{
|
||||||
|
private static readonly DateTimeOffset Now = new(2026, 7, 23, 0, 0, 0, TimeSpan.Zero);
|
||||||
|
|
||||||
|
// The moment the reminder window opens: inscribed exactly (geldigheid - herinneringstermijn) ago.
|
||||||
|
private static DateTimeOffset InscribedSoDueAt(DateTimeOffset asOf)
|
||||||
|
=> asOf - Registration.HerregistratieGeldigheid + Registration.Herinneringstermijn;
|
||||||
|
|
||||||
|
private static Registration Inscribed(DateTimeOffset ingeschrevenOp)
|
||||||
|
{
|
||||||
|
var registration = Registration.Submit("123456782");
|
||||||
|
registration.AttachZaak(FakeAclClient.DefaultZaakUrl);
|
||||||
|
registration.Approve(ingeschrevenOp);
|
||||||
|
return registration;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Approving_records_the_inscription_moment_and_the_herregistratie_deadline()
|
||||||
|
{
|
||||||
|
var registration = Inscribed(Now);
|
||||||
|
|
||||||
|
Assert.Equal(Now, registration.IngeschrevenOp);
|
||||||
|
Assert.Equal(Now + Registration.HerregistratieGeldigheid, registration.HerregistratieVoor);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void A_reminder_is_due_the_moment_the_window_before_the_deadline_opens()
|
||||||
|
{
|
||||||
|
var registration = Inscribed(InscribedSoDueAt(Now));
|
||||||
|
|
||||||
|
Assert.True(registration.HerregistratieReminderDue(Now));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void A_reminder_is_not_yet_due_one_day_before_the_window_opens()
|
||||||
|
{
|
||||||
|
var registration = Inscribed(InscribedSoDueAt(Now) + TimeSpan.FromDays(1));
|
||||||
|
|
||||||
|
Assert.False(registration.HerregistratieReminderDue(Now));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void A_registration_that_is_not_ingeschreven_is_never_due_and_has_no_deadline()
|
||||||
|
{
|
||||||
|
var registration = Registration.Submit("123456782"); // INGEDIEND, never inscribed
|
||||||
|
|
||||||
|
Assert.Null(registration.IngeschrevenOp);
|
||||||
|
Assert.Null(registration.HerregistratieVoor);
|
||||||
|
Assert.False(registration.HerregistratieReminderDue(Now));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void A_reminded_registration_is_no_longer_due()
|
||||||
|
{
|
||||||
|
var registration = Inscribed(InscribedSoDueAt(Now));
|
||||||
|
|
||||||
|
registration.MarkHerregistratieReminderVerstuurd();
|
||||||
|
|
||||||
|
Assert.True(registration.HerregistratieReminderVerstuurd);
|
||||||
|
Assert.False(registration.HerregistratieReminderDue(Now));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Marking_the_reminder_sent_twice_is_idempotent()
|
||||||
|
{
|
||||||
|
var registration = Inscribed(InscribedSoDueAt(Now));
|
||||||
|
|
||||||
|
registration.MarkHerregistratieReminderVerstuurd();
|
||||||
|
registration.MarkHerregistratieReminderVerstuurd();
|
||||||
|
|
||||||
|
Assert.True(registration.HerregistratieReminderVerstuurd);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Marking_a_reminder_on_a_registration_that_is_not_ingeschreven_is_rejected()
|
||||||
|
{
|
||||||
|
var registration = Registration.Submit("123456782");
|
||||||
|
|
||||||
|
var ex = Assert.Throws<InvalidOperationException>(() => registration.MarkHerregistratieReminderVerstuurd());
|
||||||
|
Assert.Contains("INGESCHREVEN", ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,9 @@ namespace Big.Tests;
|
|||||||
|
|
||||||
public class RegistrationTests
|
public class RegistrationTests
|
||||||
{
|
{
|
||||||
|
// A fixed inscription moment for the approval tests; its exact value is irrelevant to them.
|
||||||
|
private static readonly DateTimeOffset Ingeschreven = new(2026, 1, 1, 0, 0, 0, TimeSpan.Zero);
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Submitting_a_registration_starts_in_ingediend()
|
public void Submitting_a_registration_starts_in_ingediend()
|
||||||
{
|
{
|
||||||
@@ -103,7 +106,7 @@ public class RegistrationTests
|
|||||||
var registration = Registration.Submit("123456782");
|
var registration = Registration.Submit("123456782");
|
||||||
registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
||||||
|
|
||||||
registration.Approve();
|
registration.Approve(Ingeschreven);
|
||||||
|
|
||||||
Assert.Equal(RegistrationStatus.Ingeschreven, registration.Status);
|
Assert.Equal(RegistrationStatus.Ingeschreven, registration.Status);
|
||||||
}
|
}
|
||||||
@@ -113,7 +116,7 @@ public class RegistrationTests
|
|||||||
{
|
{
|
||||||
var registration = Registration.Submit("123456782");
|
var registration = Registration.Submit("123456782");
|
||||||
|
|
||||||
var ex = Assert.Throws<InvalidOperationException>(() => registration.Approve());
|
var ex = Assert.Throws<InvalidOperationException>(() => registration.Approve(Ingeschreven));
|
||||||
|
|
||||||
Assert.Contains("no zaak", ex.Message, StringComparison.OrdinalIgnoreCase);
|
Assert.Contains("no zaak", ex.Message, StringComparison.OrdinalIgnoreCase);
|
||||||
Assert.Equal(RegistrationStatus.Ingediend, registration.Status);
|
Assert.Equal(RegistrationStatus.Ingediend, registration.Status);
|
||||||
@@ -124,9 +127,9 @@ public class RegistrationTests
|
|||||||
{
|
{
|
||||||
var registration = Registration.Submit("123456782");
|
var registration = Registration.Submit("123456782");
|
||||||
registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
||||||
registration.Approve();
|
registration.Approve(Ingeschreven);
|
||||||
|
|
||||||
var ex = Assert.Throws<InvalidOperationException>(() => registration.Approve());
|
var ex = Assert.Throws<InvalidOperationException>(() => registration.Approve(Ingeschreven));
|
||||||
Assert.Contains("only an INGEDIEND", ex.Message);
|
Assert.Contains("only an INGEDIEND", ex.Message);
|
||||||
Assert.Equal(RegistrationStatus.Ingeschreven, registration.Status);
|
Assert.Equal(RegistrationStatus.Ingeschreven, registration.Status);
|
||||||
}
|
}
|
||||||
@@ -157,7 +160,7 @@ public class RegistrationTests
|
|||||||
{
|
{
|
||||||
var registration = Registration.Submit("123456782");
|
var registration = Registration.Submit("123456782");
|
||||||
registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
||||||
registration.Approve();
|
registration.Approve(Ingeschreven);
|
||||||
|
|
||||||
var ex = Assert.Throws<InvalidOperationException>(() => registration.TakeIntoBehandeling());
|
var ex = Assert.Throws<InvalidOperationException>(() => registration.TakeIntoBehandeling());
|
||||||
Assert.Contains("only an INGEDIEND", ex.Message);
|
Assert.Contains("only an INGEDIEND", ex.Message);
|
||||||
@@ -171,7 +174,7 @@ public class RegistrationTests
|
|||||||
registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
||||||
registration.TakeIntoBehandeling();
|
registration.TakeIntoBehandeling();
|
||||||
|
|
||||||
registration.Approve();
|
registration.Approve(Ingeschreven);
|
||||||
|
|
||||||
Assert.Equal(RegistrationStatus.Ingeschreven, registration.Status);
|
Assert.Equal(RegistrationStatus.Ingeschreven, registration.Status);
|
||||||
}
|
}
|
||||||
@@ -218,7 +221,7 @@ public class RegistrationTests
|
|||||||
var approveEx = Assert.Throws<InvalidOperationException>(() =>
|
var approveEx = Assert.Throws<InvalidOperationException>(() =>
|
||||||
{
|
{
|
||||||
registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
||||||
registration.Approve();
|
registration.Approve(Ingeschreven);
|
||||||
});
|
});
|
||||||
Assert.Contains("IN_BEHANDELING", approveEx.Message);
|
Assert.Contains("IN_BEHANDELING", approveEx.Message);
|
||||||
|
|
||||||
@@ -277,7 +280,7 @@ public class RegistrationTests
|
|||||||
{
|
{
|
||||||
var registration = Registration.Submit("123456782");
|
var registration = Registration.Submit("123456782");
|
||||||
registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
||||||
registration.Approve();
|
registration.Approve(Ingeschreven);
|
||||||
|
|
||||||
var ex = Assert.Throws<InvalidOperationException>(() => registration.Withdraw());
|
var ex = Assert.Throws<InvalidOperationException>(() => registration.Withdraw());
|
||||||
Assert.Contains("only an INGEDIEND", ex.Message);
|
Assert.Contains("only an INGEDIEND", ex.Message);
|
||||||
@@ -336,7 +339,7 @@ public class RegistrationTests
|
|||||||
{
|
{
|
||||||
var registration = Registration.Submit("123456782");
|
var registration = Registration.Submit("123456782");
|
||||||
registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
||||||
registration.Approve();
|
registration.Approve(Ingeschreven);
|
||||||
|
|
||||||
var ex = Assert.Throws<InvalidOperationException>(() => registration.Expire());
|
var ex = Assert.Throws<InvalidOperationException>(() => registration.Expire());
|
||||||
Assert.Contains("only an INGEDIEND", ex.Message);
|
Assert.Contains("only an INGEDIEND", ex.Message);
|
||||||
|
|||||||
Reference in New Issue
Block a user