Path: redb-route/tests/redb.Route.Tests.Xml/HeaderFilterStrategyReferenceGateTests.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/HeaderFilterStrategyReferenceGateTests.cs
----
using AwesomeAssertions;
using redb.Route.Core;
using redb.Route.Xml;
using redb.Route.Xml.Packaging;
namespace redb.Route.Tests.Xml;
///
/// headerFilterStrategy=#name in an endpoint URI, at the package gate: a name no bean declares is the usual
/// undeclared-reference warning, and with the built assemblies at hand the named bean is held against
/// , as a typed element attribute is.
///
public sealed class HeaderFilterStrategyReferenceGateTests : IDisposable
{
private readonly string _root = Path.Combine(Path.GetTempPath(), "redb-xml-hfs-" + Guid.NewGuid().ToString("N"));
public HeaderFilterStrategyReferenceGateTests() => Directory.CreateDirectory(_root);
public void Dispose() => Directory.Delete(_root, recursive: true);
private static Type? Resolve(string typeName) => Type.GetType(typeName);
private static string T() => $"{typeof(TType).FullName}, {typeof(TType).Assembly.GetName().Name}";
private string Project(string beans)
{
var dir = RouteProjectScaffold.Create(_root, "Hfs" + Guid.NewGuid().ToString("N")[..6]);
File.WriteAllText(Path.Combine(dir, "routes", "main.route.xml"), $"""
{beans}
""");
return dir;
}
[Fact]
public void AMissingStrategy_IsTheUndeclaredReferenceWarning()
{
var result = RoutePackage.Check(Project(""), "p", "1.0.0", Resolve);
result.Warnings.Should().Contain(w => w.Message.Contains("'#filter' is not declared"));
result.Errors.Should().BeEmpty();
}
[Fact]
public void AStrategyBean_Passes()
{
var dir = Project($"""""");
RoutePackage.Check(dir, "p", "1.0.0", Resolve).Errors.Should().BeEmpty();
}
[Fact]
public void ABeanOfTheWrongType_IsAnError_InTheEnginesWords()
{
var dir = Project($"""""");
RoutePackage.Check(dir, "p", "1.0.0", Resolve).Errors.Should().Contain(e =>
e.File.StartsWith("routes/main.route.xml(5,")
&& e.Message.Contains($"'filter' is registered as {typeof(DeepBeanTarget).FullName}, which is not an IHeaderFilterStrategy"));
}
}