Submit requires a bsn and starts the aggregate in INGEDIEND; the started process-instance id is recorded; AttachZaak stores the ACL's zaak URL, tolerating a duplicate (at-least-once worker delivery) and rejecting a conflicting URL, without advancing the status. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
78 lines
2.3 KiB
C#
78 lines
2.3 KiB
C#
using Big.Domain;
|
|
|
|
namespace Big.Tests;
|
|
|
|
public class RegistrationTests
|
|
{
|
|
[Fact]
|
|
public void Submitting_a_registration_starts_in_ingediend()
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
|
|
Assert.Equal(RegistrationStatus.Ingediend, registration.Status);
|
|
Assert.Equal("123456782", registration.Bsn);
|
|
Assert.NotEqual(Guid.Empty, registration.Id.Value);
|
|
Assert.Null(registration.ZaakUrl);
|
|
Assert.Null(registration.ProcessInstanceId);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("")]
|
|
[InlineData(" ")]
|
|
[InlineData(null)]
|
|
public void Submitting_without_a_bsn_is_rejected(string? bsn)
|
|
=> Assert.ThrowsAny<ArgumentException>(() => Registration.Submit(bsn!));
|
|
|
|
[Fact]
|
|
public void Recording_the_started_process_keeps_its_instance_id()
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
|
|
registration.RecordProcessStarted("proc-42");
|
|
|
|
Assert.Equal("proc-42", registration.ProcessInstanceId);
|
|
}
|
|
|
|
[Fact]
|
|
public void Attaching_a_zaak_records_its_url_and_keeps_the_status_ingediend()
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
var zaak = new Uri("http://openzaak/zaken/api/v1/zaken/abc");
|
|
|
|
registration.AttachZaak(zaak);
|
|
|
|
Assert.Equal(zaak, registration.ZaakUrl);
|
|
Assert.Equal(RegistrationStatus.Ingediend, registration.Status);
|
|
}
|
|
|
|
[Fact]
|
|
public void Attaching_a_null_zaak_is_rejected()
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
|
|
Assert.Throws<ArgumentNullException>(() => registration.AttachZaak(null!));
|
|
}
|
|
|
|
[Fact]
|
|
public void Re_attaching_the_same_zaak_is_idempotent()
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
var zaak = new Uri("http://openzaak/zaken/api/v1/zaken/abc");
|
|
|
|
registration.AttachZaak(zaak);
|
|
registration.AttachZaak(zaak);
|
|
|
|
Assert.Equal(zaak, registration.ZaakUrl);
|
|
}
|
|
|
|
[Fact]
|
|
public void Attaching_a_conflicting_zaak_is_rejected()
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
|
|
|
Assert.Throws<InvalidOperationException>(
|
|
() => registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/other")));
|
|
}
|
|
}
|