Path: redb-route/tests/redb.Route.Tests/Xslt/XsltEngineSubstitutionTests.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/XsltEngineSubstitutionTests.cs
----
using AwesomeAssertions;
using Microsoft.Extensions.DependencyInjection;
using redb.Route.Abstractions;
using redb.Route.Core;
using redb.Route.Xslt;
namespace redb.Route.Tests.Xslt;
///
/// has been an interface since 3.5.0, and its documentation said another
/// engine could be plugged in. It could not: the DSL verbs and the component each named
/// directly, so there was no seam behind the interface.
///
/// Substitution now goes through — the factory rather than the
/// engine, because a stylesheet has to be compiled, and compiling is exactly what a different
/// processor does differently. These tests cover all three places a stylesheet gets compiled, plus
/// the default staying the default.
///
///
public class XsltEngineSubstitutionTests : IAsyncLifetime
{
private const string Stylesheet =
"""
""";
private const string Input = "world";
private const string BclResult = "world";
private readonly string _stylesheetFile;
public XsltEngineSubstitutionTests()
{
_stylesheetFile = Path.Combine(Path.GetTempPath(), $"redb-xslt-sub-{Guid.NewGuid():N}.xsl");
File.WriteAllText(_stylesheetFile, Stylesheet);
}
public Task InitializeAsync() => Task.CompletedTask;
public Task DisposeAsync()
{
try { File.Delete(_stylesheetFile); } catch (IOException) { /* the temp file outlives the test at worst */ }
GC.SuppressFinalize(this);
return Task.CompletedTask;
}
// ── A stand-in processor ──
/// An engine that ignores the stylesheet and reports what it was handed.
private sealed class StubEngine(string origin) : IXsltEngine
{
public object Transform(object? body, XsltOutput output, IReadOnlyDictionary? parameters)
=> $"stub[{origin}]:{body}";
}
private sealed class StubFactory : IXsltEngineFactory
{
public int FileCompilations { get; private set; }
public int ContentCompilations { get; private set; }
public IXsltEngine FromFile(string stylesheetPath)
{
FileCompilations++;
return new StubEngine("file");
}
public IXsltEngine FromContent(string stylesheetXml)
{
ContentCompilations++;
return new StubEngine("content");
}
}
// ── Harness ──
private static async Task