Path: redb-route/tests/redb.Route.Tests.Xml/RedbDataSourceReferenceGateTests.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/RedbDataSourceReferenceGateTests.cs
----
using AwesomeAssertions;
using redb.Route.Sql;
using redb.Route.Xml;
using redb.Route.Xml.Packaging;
namespace redb.Route.Tests.Xml;
///
/// dataSource=redb and dataSource=redb:<name> name the sql: data source redb.Route.Core registers at
/// start, so the package gate does not report them as references no <bean> declares. Any other undeclared data
/// source is still the usual warning.
///
public sealed class RedbDataSourceReferenceGateTests : IDisposable
{
private readonly string _root = Path.Combine(Path.GetTempPath(), "redb-xml-redbds-" + Guid.NewGuid().ToString("N"));
public RedbDataSourceReferenceGateTests() => Directory.CreateDirectory(_root);
public void Dispose() => Directory.Delete(_root, recursive: true);
private static readonly IReadOnlyList Catalog = ComponentCatalog.Build([new SqlComponent()]);
private IEnumerable Undeclared(string step)
{
var dir = RouteProjectScaffold.Create(_root, "Rds" + Guid.NewGuid().ToString("N")[..6]);
File.WriteAllText(Path.Combine(dir, "routes", "main.route.xml"), $"""
{step}
""");
return RoutePackage.Check(dir, "p", "1.0.0", catalog: Catalog).Warnings
.Select(w => w.Message)
.Where(m => m.Contains("is not declared by any ", StringComparison.Ordinal));
}
[Theory]
[InlineData("""""")]
[InlineData("""""")]
[InlineData("""""")]
[InlineData("""""")]
public void TheRedbDataSource_IsNotAnUndeclaredReference(string step)
{
Undeclared(step).Should().BeEmpty();
}
[Fact]
public void AnotherUndeclaredDataSource_IsStillReported()
{
Undeclared("""""")
.Should().ContainSingle().Which.Should().StartWith("'#main' is not declared");
}
}