Path: redb-route/tests/redb.Route.Tests.Xml/PoolAttributesXmlTests.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/PoolAttributesXmlTests.cs
----
using System.Xml.Linq;
using AwesomeAssertions;
using redb.Route.Configuration;
using redb.Route.Core;
using redb.Route.Xml;
namespace redb.Route.Tests.Xml;
///
/// The pool attributes of Camel's XML DSL: executorService on <wireTap>, parallelProcessing
/// and executorService on <onCompletion>, in the loaded route and in the generated C#.
///
public class PoolAttributesXmlTests : IAsyncLifetime
{
private readonly RouteContext _context = new();
public Task InitializeAsync() => Task.CompletedTask;
public async Task DisposeAsync() => await _context.DisposeAsync();
private const string Routes = """
""";
[Fact]
public async Task TheAttributes_LoadAndBuild_WithTheNamedProfileRegistered()
{
_context.AddThreadPoolProfile("audit", new ThreadPoolProfile { MaxConcurrency = 4 });
_context.AddXmlRoutesFromContent(Routes, "");
var act = () => _context.Start();
await act.Should().NotThrowAsync();
_context.Routes.Select(r => r.RouteId).Should().Contain("pool-xml");
}
[Theory]
[InlineData("""""")]
[InlineData("""""")]
public async Task AnUnknownProfile_FailsTheRouteBuild_NamingIt(string step)
{
_context.AddXmlRoutesFromContent($"""
{step}
""", "");
var act = () => _context.Start();
await act.Should().ThrowAsync().Where(e => Mentions(e, "no-such-pool"));
}
[Fact]
public void TheGeneratedCode_CarriesTheAttributes()
{
var code = XmlCodeGenerator.Generate(XDocument.Parse(Routes), "Pools", "Tests.Generated", sourceName: "");
code.Should().Contain("WireTap(\"direct://pool-xml-sink\", executorService: \"audit\")");
code.Should().Contain("ParallelProcessing()");
code.Should().Contain("ExecutorService(\"audit\")");
}
private static bool Mentions(Exception? e, string text)
{
for (; e is not null; e = e.InnerException)
if (e.Message.Contains(text, StringComparison.Ordinal))
return true;
return false;
}
}