Path: redb-route/tests/redb.Route.Validation.Adapters.Tests/ValidationDslExtensionsTests.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.Validation.Adapters.Tests/ValidationDslExtensionsTests.cs ---- using AwesomeAssertions; using FluentValidation; using redb.Route.Core; using redb.Route.Validation; using Xunit; namespace redb.Route.Validation.Adapters.Tests; public class ValidationDslExtensionsTests { public sealed class Item { public string Name { get; set; } = ""; } private sealed class ItemValidator : AbstractValidator { public ItemValidator() => RuleFor(x => x.Name).NotEmpty(); } [Fact] public async Task ValidateFluent_Error_ThrowsByDefault() { await using var ctx = new RouteContext(); ctx.AddRoutes(r => { r.From("direct://fv-error") .ValidateFluent(new ItemValidator()) .Process(_ => { }); }); await ctx.Start(); var producer = ctx.GetEndpoint("direct://fv-error").CreateProducer(); await producer.Start(); var act = async () => await producer.Process(new Exchange(new Message(new Item()))); await act.Should().ThrowAsync(); } [Fact] public async Task ValidateFluent_Warning_DoesNotThrow_AndSetsHeader() { await using var ctx = new RouteContext(); Exchange? captured = null; ctx.AddRoutes(r => { r.From("direct://fv-warn") .ValidateFluent(new ItemValidator(), ValidationSeverity.Warning) .Process(e => captured = (Exchange)e); }); await ctx.Start(); var producer = ctx.GetEndpoint("direct://fv-warn").CreateProducer(); await producer.Start(); await producer.Process(new Exchange(new Message(new Item()))); captured.Should().NotBeNull(); captured!.In.Headers.Should().ContainKey(ValidateProcessor.ValidationWarningsHeader); } [Fact] public async Task ValidateAnnotations_Warning_DoesNotThrow() { await using var ctx = new RouteContext(); ctx.AddRoutes(r => { r.From("direct://da-warn") .ValidateAnnotations(ValidationSeverity.Warning) .Process(_ => { }); }); await ctx.Start(); var producer = ctx.GetEndpoint("direct://da-warn").CreateProducer(); await producer.Start(); var act = async () => await producer.Process( new Exchange(new Message(new FluentValidationMessageValidatorTests.Person()))); await act.Should().NotThrowAsync(); } }