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