test(domain): lock beoordeling transitions — reject, idempotent re-take, guards (refs #13)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -131,4 +131,90 @@ public class RegistrationTests
|
|||||||
|
|
||||||
Assert.Equal(RegistrationStatus.InBehandeling, registration.Status);
|
Assert.Equal(RegistrationStatus.InBehandeling, registration.Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Re_taking_an_in_behandeling_registration_is_idempotent()
|
||||||
|
{
|
||||||
|
var registration = Registration.Submit("123456782");
|
||||||
|
registration.TakeIntoBehandeling();
|
||||||
|
|
||||||
|
registration.TakeIntoBehandeling();
|
||||||
|
|
||||||
|
Assert.Equal(RegistrationStatus.InBehandeling, registration.Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Taking_a_decided_registration_into_behandeling_is_rejected()
|
||||||
|
{
|
||||||
|
var registration = Registration.Submit("123456782");
|
||||||
|
registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
||||||
|
registration.Approve();
|
||||||
|
|
||||||
|
var ex = Assert.Throws<InvalidOperationException>(() => registration.TakeIntoBehandeling());
|
||||||
|
Assert.Contains("only an INGEDIEND", ex.Message);
|
||||||
|
Assert.Equal(RegistrationStatus.Ingeschreven, registration.Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Approving_an_in_behandeling_registration_with_a_zaak_sets_it_ingeschreven()
|
||||||
|
{
|
||||||
|
var registration = Registration.Submit("123456782");
|
||||||
|
registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
||||||
|
registration.TakeIntoBehandeling();
|
||||||
|
|
||||||
|
registration.Approve();
|
||||||
|
|
||||||
|
Assert.Equal(RegistrationStatus.Ingeschreven, registration.Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Rejecting_a_registration_sets_it_afgewezen()
|
||||||
|
{
|
||||||
|
var registration = Registration.Submit("123456782");
|
||||||
|
|
||||||
|
registration.Reject();
|
||||||
|
|
||||||
|
Assert.Equal(RegistrationStatus.Afgewezen, registration.Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Rejecting_needs_no_zaak()
|
||||||
|
{
|
||||||
|
// A registration can be turned down before its zaak is ever opened, so Reject must not require one.
|
||||||
|
var registration = Registration.Submit("123456782");
|
||||||
|
|
||||||
|
registration.Reject();
|
||||||
|
|
||||||
|
Assert.Equal(RegistrationStatus.Afgewezen, registration.Status);
|
||||||
|
Assert.Null(registration.ZaakUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Rejecting_an_in_behandeling_registration_sets_it_afgewezen()
|
||||||
|
{
|
||||||
|
var registration = Registration.Submit("123456782");
|
||||||
|
registration.TakeIntoBehandeling();
|
||||||
|
|
||||||
|
registration.Reject();
|
||||||
|
|
||||||
|
Assert.Equal(RegistrationStatus.Afgewezen, registration.Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Deciding_an_already_decided_registration_is_rejected()
|
||||||
|
{
|
||||||
|
var registration = Registration.Submit("123456782");
|
||||||
|
registration.Reject();
|
||||||
|
|
||||||
|
var approveEx = Assert.Throws<InvalidOperationException>(() =>
|
||||||
|
{
|
||||||
|
registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
||||||
|
registration.Approve();
|
||||||
|
});
|
||||||
|
Assert.Contains("IN_BEHANDELING", approveEx.Message);
|
||||||
|
|
||||||
|
var rejectEx = Assert.Throws<InvalidOperationException>(() => registration.Reject());
|
||||||
|
Assert.Contains("Afgewezen", rejectEx.Message);
|
||||||
|
Assert.Equal(RegistrationStatus.Afgewezen, registration.Status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user