test(domain): Registration aggregate invariants (refs #6)
Failing unit tests for the Registration aggregate root: a submission starts in INGEDIEND carrying its bsn, an empty/whitespace/null bsn is rejected, the started process-instance id is remembered, and attaching the zaak the ACL opened records its URL idempotently (a conflicting URL is rejected) while the status stays INGEDIEND. The aggregate is a stub (no-op mutators, empty bsn) so the tests compile and fail on their assertions; the green commit implements the invariants. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
25
services/domain/Big.Tests/Big.Tests.csproj
Normal file
25
services/domain/Big.Tests/Big.Tests.csproj
Normal file
@@ -0,0 +1,25 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.4" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
||||
<PackageReference Include="xunit" Version="2.9.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="Xunit" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Big.Domain\Big.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
77
services/domain/Big.Tests/RegistrationTests.cs
Normal file
77
services/domain/Big.Tests/RegistrationTests.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
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.Throws<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")));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user