Path: redb-route/tests/redb.Route.Tests.As2/As2ConcurrencyLimitOptionsTests.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.As2/As2ConcurrencyLimitOptionsTests.cs ---- using AwesomeAssertions; using redb.Route.As2; using redb.Route.Core; using Xunit; using As2Dsl = redb.Route.As2.Fluent.As2; namespace redb.Route.Tests.As2; /// /// Admission-limit options on the AS2 receiver. /// AS2 partners retry on their own MDN timeouts, so early shedding is cheaper than a saturated /// receiver doing S/MIME work it will never finish. The shed mechanics are e2e-proved on the /// shared host and the HTTP connector; here — that AS2 carries the quartet end to end. /// public sealed class As2ConcurrencyLimitOptionsTests { [Fact] public void UriAndDsl_CarryTheOptions() { var built = As2Dsl.Receive("/as2/in") .Port(4080) .MaxConcurrentRequests(2, queue: 4) .RejectStatusCode(503) .RetryAfterSeconds(0) .Build(); built.Should().Contain("maxConcurrentRequests=2") .And.Contain("requestQueueLimit=4") .And.Contain("rejectStatusCode=503") .And.Contain("retryAfterSeconds=0"); var endpoint = (As2Endpoint)new As2Component().CreateEndpoint(EndpointUriParser.Parse(built)); endpoint.EndpointOptions.MaxConcurrentRequests.Should().Be(2); endpoint.EndpointOptions.RequestQueueLimit.Should().Be(4); endpoint.EndpointOptions.RejectStatusCode.Should().Be(503); endpoint.EndpointOptions.RetryAfterSeconds.Should().Be(0); } [Fact] public void QueueWithoutLimit_FailsLoud() { var uri = EndpointUriParser.Parse("as2:/in?port=4082&maxConcurrentRequests=0&requestQueueLimit=3"); var act = () => new As2Component().CreateEndpoint(uri); act.Should().Throw().WithMessage("*requestQueueLimit*maxConcurrentRequests*"); } [Theory] [InlineData("", 32, 32)] [InlineData("&maxConcurrentRequests=0", 0, 0)] [InlineData("&maxConcurrentRequests=8", 8, 32)] [InlineData("&maxConcurrentRequests=8&requestQueueLimit=0", 8, 0)] [InlineData("&requestQueueLimit=5", 32, 5)] public void Defaults_AreBounded_ZeroIsUnlimited(string query, int max, int queue) { var endpoint = (As2Endpoint)new As2Component().CreateEndpoint(EndpointUriParser.Parse("as2:/in?port=4084" + query)); endpoint.EndpointOptions.MaxConcurrentRequests.Should().Be(max); endpoint.EndpointOptions.RequestQueueLimit.Should().Be(queue); } [Fact] public void Dsl_CarriesAnExplicitZero() { As2Dsl.Receive("/as2/in").Port(4080).MaxConcurrentRequests(0).Build() .Should().Contain("maxConcurrentRequests=0").And.NotContain("requestQueueLimit"); As2Dsl.Receive("/as2/in").Port(4080).MaxConcurrentRequests(8, queue: 0).Build() .Should().Contain("maxConcurrentRequests=8").And.Contain("requestQueueLimit=0"); As2Dsl.Receive("/as2/in").Port(4080).Build() .Should().NotContain("maxConcurrentRequests").And.NotContain("requestQueueLimit"); } }