Path: redb-route/tests/redb.Route.Tests/Xslt/XsltProcessorTests.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/Xslt/XsltProcessorTests.cs
----
using AwesomeAssertions;
using redb.Route.Core;
using redb.Route.Xslt;
namespace redb.Route.Tests.Xslt;
/// Tests for body/null handling.
public class XsltProcessorTests
{
private const string Stylesheet =
"""
""";
private static XsltProcessor NewProcessor(bool failOnNullBody = true)
=> new(XslCompiledTransformEngine.FromContent(Stylesheet), XsltOutput.String, failOnNullBody);
[Fact]
public async Task Process_TransformsBody_InPlace()
{
var exchange = new Exchange(new Message("world"));
await NewProcessor().Process(exchange);
exchange.In.Body.Should().Be("world");
}
[Fact]
public async Task Process_NullBody_ThrowsWhenFailOnNull()
{
var exchange = new Exchange(new Message(null));
var act = () => NewProcessor(failOnNullBody: true).Process(exchange);
await act.Should().ThrowAsync();
}
[Fact]
public async Task Process_NullBody_PassesThroughWhenNotFailOnNull()
{
var exchange = new Exchange(new Message(null));
await NewProcessor(failOnNullBody: false).Process(exchange);
exchange.In.Body.Should().BeNull();
}
[Fact]
public void Constructor_NullEngine_Throws()
{
var act = () => new XsltProcessor(null!);
act.Should().Throw().WithParameterName("engine");
}
}