Path: redb-route/tests/redb.Route.Tests.Xml/DeadLetterChannelXmlTests.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.Xml/DeadLetterChannelXmlTests.cs
----
using AwesomeAssertions;
using redb.Route.Core;
using redb.Route.ErrorHandling;
using redb.Route.TestKit;
using redb.Route.Xml;
namespace redb.Route.Tests.Xml;
///
/// <deadLetterChannel uri="..."/> in context.xml — the context's dead letter channel, Apache Camel's
/// errorHandlerRef on <camelContext>: a context-level element only, and one error handler per context.
///
public class DeadLetterChannelXmlTests : IAsyncLifetime
{
private readonly RouteContext _context = new();
public Task InitializeAsync() => Task.CompletedTask;
public async Task DisposeAsync()
{
await _context.DisposeAsync();
GC.SuppressFinalize(this);
}
[Fact]
public async Task InContext_EveryRouteSendsItsUntakenFailureThere()
{
_context.AddXmlContextFromContent("""
""", "");
_context.AddXmlRoutesFromContent("""
""", "");
await _context.Start();
_context.ErrorHandler.Should().BeOfType()
.Which.DeadLetterUri.Should().Be("mock://xml-dlc-errors");
try { await _context.SendBody("direct://xml-dlc-orders", "x"); }
catch (InvalidOperationException) { }
await _context.Mock("mock://xml-dlc-errors").ExpectBodies("x").AssertIsSatisfiedAsync(TimeSpan.FromSeconds(2));
}
[Fact]
public void InARoute_IsAPositionedError()
{
var act = () => _context.AddXmlRoutesFromContent("""
""", "");
act.Should().Throw();
}
[Fact]
public void OverAnErrorHandlerAlreadySet_IsAnError()
{
_context.ErrorHandler = new DeadLetterErrorHandler(_context, "mock://first");
var act = () => _context.AddXmlContextFromContent("""
""", "");
act.Should().Throw().WithMessage("*already has an error handler*");
}
}