Files
register-referentie/services/domain/Big.Tests/RegistrationHerregistratieTests.cs
T
not dc532dee00 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
2026-07-23 11:51:11 +02:00

91 lines
3.3 KiB
C#

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);
}
}