test(backend): split RuleTests.cs by aggregate, refresh DDD doc (WP-71)

RuleTests.cs held five aggregates' rules as nested classes in one file,
misaligned with Domain/<Aggregate>/ and with the Acceptance/Builders/
folder convention WP-70 started. Split into Domain/<Aggregate>RuleTests.cs
(pure move — same names, same bodies, same count) plus a new
ApplicationRuleTests.cs (the enum invariant moved out of the
WebApplicationFactory-booting ApplicationTests.cs, since it's a pure
Enum.GetNames check with no business needing a web host) and
OrgTemplateRuleTests.cs (RejectDraft had no direct unit test before,
only endpoint coverage).

libs/shared/docs/layers.mdx still taught the pre-WP-67 shape (six
contexts, no apps/libs split, enforcement via ESLint) — updated to the
real monorepo structure and to dependency-cruiser as the actual
enforcement mechanism. Adds specs for registration.policy.ts's
isStatusConsistent (untested; its backend mirror is) and both apps'
auth/domain/session.ts.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
eho
2026-08-18 20:25:05 +02:00
co-authored by Claude Sonnet 5
parent b937e55ad3
commit 28c0a250e7
13 changed files with 409 additions and 254 deletions
@@ -0,0 +1,43 @@
using BigRegister.Api.Contracts;
using BigRegister.Domain.Letters;
namespace BigRegister.Tests.Domain;
public class OrgTemplateRuleTests
{
private static OrgTemplateDto Draft(
string orgName = "BIG-register",
string signatureName = "J. Jansen",
MarginsDto? margins = null) =>
new(
SubOrgId: "registers", OrgName: orgName, ReturnAddress: "Postbus 1, Den Haag",
LogoDocumentId: null, FooterContact: "info@example.nl", FooterLegal: "KvK 12345678",
SignatureName: signatureName, SignatureRole: "Manager", SignatureClosing: "Met vriendelijke groet",
Margins: margins ?? new MarginsDto(20, 20, 20, 20));
[Fact]
public void Accepts_a_complete_draft_within_the_margin_bounds() =>
Assert.Null(OrgTemplateRules.RejectDraft(Draft()));
[Fact]
public void Rejects_a_missing_organisation_name() =>
Assert.NotNull(OrgTemplateRules.RejectDraft(Draft(orgName: "")));
[Fact]
public void Rejects_a_missing_signature_name() =>
Assert.NotNull(OrgTemplateRules.RejectDraft(Draft(signatureName: " ")));
[Theory]
[InlineData(9, 20, 20, 20)] // top just under the minimum
[InlineData(20, 51, 20, 20)] // right just over the maximum
[InlineData(20, 20, 9, 20)] // bottom under the minimum
[InlineData(20, 20, 20, 51)] // left over the maximum
public void Rejects_a_margin_outside_the_allowed_range(int top, int right, int bottom, int left) =>
Assert.NotNull(OrgTemplateRules.RejectDraft(Draft(margins: new MarginsDto(top, right, bottom, left))));
[Theory]
[InlineData(10, 10, 10, 10)] // the minimum, inclusive
[InlineData(50, 50, 50, 50)] // the maximum, inclusive
public void Accepts_margins_on_the_boundary(int top, int right, int bottom, int left) =>
Assert.Null(OrgTemplateRules.RejectDraft(Draft(margins: new MarginsDto(top, right, bottom, left))));
}