Path: redb-route/tests/redb.Route.Tests.Xml/RoutePackagingTests.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/RoutePackagingTests.cs ---- using System.IO.Compression; using System.Text.Json; using AwesomeAssertions; using redb.Route.Xml; using redb.Route.Xml.Packaging; namespace redb.Route.Tests.Xml; /// The bean target of the deep packaging checks. public class DeepBeanTarget { public string? Endpoint { get; set; } public string Handle(Abstractions.IExchange exchange) => "ok"; } /// /// The Tsak-independent half: a scaffolded project builds into the package /// layout (manifest + L4 identity config + artifacts + resources) with the packaging checks as the /// gate — a broken reference is a build error, never a deployment surprise — and every /// {{key}} without a default lands in the required-keys manifest. /// public class RoutePackagingTests : IDisposable { private readonly string _root = Path.Combine(Path.GetTempPath(), "redb-xml-pkg-" + Guid.NewGuid().ToString("N")); public RoutePackagingTests() => Directory.CreateDirectory(_root); public void Dispose() => Directory.Delete(_root, recursive: true); private string NewProject(string name = "Orders", string? context = null) => RouteProjectScaffold.Create(_root, name, context); // ── the scaffold ───────────────────────────────────────────────────────── [Fact] public void Scaffold_CreatesTheWholeConvention() { var dir = NewProject("Orders", "orders"); File.Exists(Path.Combine(dir, "Orders.csproj")).Should().BeTrue(); File.Exists(Path.Combine(dir, "context.xml")).Should().BeTrue(); File.Exists(Path.Combine(dir, "routes", "main.route.xml")).Should().BeTrue(); File.Exists(Path.Combine(dir, "config", "Orders.config.json")).Should().BeTrue(); File.Exists(Path.Combine(dir, "config", "context.sample.json")).Should().BeTrue(); File.Exists(Path.Combine(dir, "schema", "redb-route-1.0.xsd")).Should().BeTrue(); File.Exists(Path.Combine(dir, ".vscode", "settings.json")).Should().BeTrue(); // A route project is a library: without this NuGet assemblies never reach bin/, and the // build-time pack gate (--bin TargetDir) sees neither connectors nor markup contributions. File.ReadAllText(Path.Combine(dir, "Orders.csproj")) .Should().Contain("true", "the build-time gate reads the runtime from TargetDir"); // The L4 config is module identity ONLY — no settings, no secrets. using var l4 = JsonDocument.Parse(File.ReadAllText(Path.Combine(dir, "config", "Orders.config.json"))); l4.RootElement.EnumerateObject().Select(p => p.Name) .Should().BeEquivalentTo("//", "ContextName", "AutoStart"); l4.RootElement.GetProperty("ContextName").GetString().Should().Be("orders"); } [Fact] public void Scaffold_RefusesANonEmptyDirectory() { var dir = NewProject("Busy"); var act = () => RouteProjectScaffold.Create(_root, "Busy"); act.Should().Throw().WithMessage("*not empty*"); } // ── check and build ────────────────────────────────────────────────────── [Fact] public void FreshScaffold_PassesTheChecks_AndBuildsThePackage() { // The package name `pack` infers is the project name; the context comes from config/Orders.config.json. var dir = NewProject("Orders", "sales"); var outDir = Path.Combine(_root, "out"); var result = RoutePackage.Build(dir, "Orders", "1.2.3", outDir); result.Errors.Should().BeEmpty(); result.Warnings.Should().BeEmpty(); result.Manifest.Artifacts.Should().Equal("routes/main.route.xml"); result.Manifest.Context.Should().Be("sales"); var stage = Path.Combine(outDir, "Orders-1.2.3"); File.Exists(Path.Combine(stage, "manifest.json")).Should().BeTrue(); File.Exists(Path.Combine(stage, "Orders.config.json")).Should().BeTrue(); File.Exists(Path.Combine(stage, "routes", "main.route.xml")).Should().BeTrue(); File.Exists(Path.Combine(stage, "context.xml")).Should().BeTrue(); using var zip = ZipFile.OpenRead(Path.Combine(outDir, "Orders-1.2.3.tpkg")); zip.Entries.Select(e => e.FullName.Replace('\\', '/')) .Should().Contain(["manifest.json", "Orders.config.json", "routes/main.route.xml"]); } /// /// The config file name is matched with its letter case on every system. File.Exists ignored the case on Windows /// and kept it on Linux, so the same project and the same --name gave two different packages. /// [Fact] public void NameDifferingOnlyInCase_IsAWarning_AndPacksTheDefaultConfig_OnEverySystem() { var dir = NewProject("Orders", "sales"); var outDir = Path.Combine(_root, "out"); var result = RoutePackage.Build(dir, "orders", "1.2.3", outDir); result.Errors.Should().BeEmpty(); result.Warnings.Should().ContainSingle(w => w.File == "config/orders.config.json") .Which.Message.Should().Contain("config/Orders.config.json"); result.Manifest.Context.Should().BeNull("config/Orders.config.json is not the config of the package 'orders'"); using var l4 = JsonDocument.Parse(File.ReadAllText(Path.Combine(outDir, "orders-1.2.3", "orders.config.json"))); l4.RootElement.GetProperty("ContextName").GetString().Should().Be("orders"); } [Fact] public void EntryGivenAsABuildPath_IsNamedInTheManifestAsTheZipEntry() { var dir = NewProject("Orders", "orders"); var bin = Path.Combine(dir, "bin", "Release", "net10.0"); Directory.CreateDirectory(bin); File.WriteAllBytes(Path.Combine(bin, "Orders.dll"), [0x4D, 0x5A]); var outDir = Path.Combine(_root, "out"); var result = RoutePackage.Build(dir, "orders", "1.0.0", outDir, entryPoints: ["bin/Release/net10.0/Orders.dll"]); result.Errors.Should().BeEmpty(); result.Manifest.EntryPoints.Should().Equal("Orders.dll"); using var zip = ZipFile.OpenRead(Path.Combine(outDir, "orders-1.0.0.tpkg")); zip.GetEntry("Orders.dll").Should().NotBeNull("the loader looks the entry point up by the manifest's name"); using var manifest = JsonDocument.Parse(zip.GetEntry("manifest.json")!.Open()); manifest.RootElement.GetProperty("EntryPoints").EnumerateArray().Select(e => e.GetString()) .Should().Equal("Orders.dll"); } /// /// --depends writes the manifest Dependencies: the worker opens the named packages (a carrier of shared companion /// DLLs) before this one. The tool had no way to write them, so a pure XML package could not declare its carrier. /// [Fact] public void Dependencies_AreWrittenToTheManifest_AsGiven() { var dir = NewProject("Orders", "orders"); var outDir = Path.Combine(_root, "out"); var result = RoutePackage.Build(dir, "orders", "1.0.0", outDir, dependencies: ["shared-beans", "Billing"]); result.Errors.Should().BeEmpty(); result.Manifest.Dependencies.Should().Equal("shared-beans", "Billing"); using var zip = ZipFile.OpenRead(Path.Combine(outDir, "orders-1.0.0.tpkg")); using var manifest = JsonDocument.Parse(zip.GetEntry("manifest.json")!.Open()); manifest.RootElement.GetProperty("Dependencies").EnumerateArray().Select(e => e.GetString()) .Should().Equal("shared-beans", "Billing"); } [Fact] public void Without_dependencies_the_manifest_lists_none() { var dir = NewProject("Orders", "orders"); var result = RoutePackage.Check(dir, "orders", "1.0.0"); result.Errors.Should().BeEmpty(); result.Manifest.Dependencies.Should().BeEmpty(); } [Theory] [InlineData("", "not a package name")] [InlineData(" billing", "not a package name")] [InlineData("--bin", "is an option")] [InlineData("carrier.tpkg", "is a file")] [InlineData("pkg/carrier", "is a file")] [InlineData("Shared.Beans.dll", "is a file")] [InlineData("ORDERS", "cannot depend on itself")] public void A_dependency_of_the_wrong_shape_is_an_error(string dependency, string message) { var dir = NewProject("Orders", "orders"); var result = RoutePackage.Check(dir, "orders", "1.0.0", dependencies: [dependency]); result.Errors.Should().ContainSingle(e => e.File == "--depends").Which.Message.Should().Contain(message); } [Fact] public void A_dependency_listed_twice_is_an_error_and_refuses_the_build() { var dir = NewProject("Orders", "orders"); var outDir = Path.Combine(_root, "out"); var result = RoutePackage.Build(dir, "orders", "1.0.0", outDir, dependencies: ["billing", "Billing"]); result.Errors.Should().ContainSingle(e => e.File == "--depends").Which.Message.Should().Contain("more than once"); File.Exists(Path.Combine(outDir, "orders-1.0.0.tpkg")).Should().BeFalse(); } [Fact] public void ConfigOfAnotherName_IsAWarning_NamingBothFiles() { var dir = NewProject("Orders", "orders"); var result = RoutePackage.Check(dir, "billing", "1.0.0"); result.Errors.Should().BeEmpty(); result.Warnings.Should().ContainSingle(w => w.File == "config/billing.config.json") .Which.Message.Should().Contain("config/billing.config.json").And.Contain("config/Orders.config.json"); } [Fact] public void ConfigOfThePackageName_OrNoConfigAtAll_IsNotWarned() { var dir = NewProject("Orders", "orders"); RoutePackage.Check(dir, "Orders", "1.0.0").Warnings .Should().NotContain(w => w.Message.Contains("reads its config from")); File.Delete(Path.Combine(dir, "config", "Orders.config.json")); RoutePackage.Check(dir, "billing", "1.0.0").Warnings .Should().NotContain(w => w.Message.Contains("reads its config from"), "without any *.config.json the default config is the intended one"); } [Fact] public void RequiredConfigKeys_AreEveryPlaceholderWithoutADefault() { var dir = NewProject("Keys", "keys"); File.WriteAllText(Path.Combine(dir, "routes", "keys.route.xml"), """ """); var result = RoutePackage.Check(dir, "keys", "1.0.0"); result.Errors.Should().BeEmpty(); result.Manifest.RequiredConfigKeys.Should().Equal("mail.from", "mail.to", "tenant.name"); result.Warnings.Should().Contain(w => w.Message.Contains("#corp-smtp"), "an undeclared #reference is named: module code may register it, or it is dangling"); } [Theory] [InlineData("${header.kind} =~ 'order'", true)] [InlineData("${header.n} range '1..10'", true)] [InlineData("${header.n} not range '1..10'", true)] [InlineData("${header.kind =~ 'order'}", false)] [InlineData("header.n range '1..10'", false)] public void TheCamelComparisons_OutsideAPlaceholder_AreWarnedToo(string condition, bool warned) { var dir = NewProject("CondCamel", "condcamel"); File.WriteAllText(Path.Combine(dir, "routes", "cond.route.xml"), $""" """); var result = RoutePackage.Check(dir, "condcamel", "1.0.0"); result.Errors.Should().BeEmpty(); result.Warnings.Any(w => w.Message.Contains("compares OUTSIDE")).Should().Be(warned); } [Fact] public void AConditionThatComparesOutsideAPlaceholder_IsAWarning() { // ${header.kind} == 'order' renders to the text «refund == 'order'», which is non-empty and // therefore true whatever the header holds: the branch always wins, silently. The gate names // the line and leaves the decision to the author — a warning, not an error. var dir = NewProject("Cond", "cond"); File.WriteAllText(Path.Combine(dir, "routes", "cond.route.xml"), """ """); var result = RoutePackage.Check(dir, "cond", "1.0.0"); result.Errors.Should().BeEmpty("a template in a condition still loads and runs"); result.Warnings.Should().ContainSingle(w => w.Message.Contains("compares OUTSIDE")) .Which.File.Should().Contain("cond.route.xml(5,", "the warning carries the position of the attribute"); } [Fact] public void ConditionsThatAreSpelledProperly_AreNotWarnedAbout() { // Three shapes that read correctly and must stay silent: the comparison without braces, a // lone placeholder (it renders to true/false and is read as a boolean word), and a // comparison entirely inside the braces (evaluated, never rendered). Plus a VALUE position, // where a template with an operator is ordinary text. var dir = NewProject("CondOk", "condok"); File.WriteAllText(Path.Combine(dir, "routes", "condok.route.xml"), """ """); var result = RoutePackage.Check(dir, "condok", "1.0.0"); result.Errors.Should().BeEmpty(); result.Warnings.Should().NotContain(w => w.Message.Contains("compares OUTSIDE")); } // ── package resources named by package elements ────────────────────────── /// The two package elements that read a file from the package, as the worker's discovery sees them. private static readonly IReadOnlyList FileReadingContributions = [ new redb.Route.Templates.PayloadXmlContribution(), new redb.Route.JsonTransform.JsonTransformXmlContribution(), ]; [Fact] public void ATemplateMissingFromResources_IsAnError() { // The worker reads from the package's resources/ (a156cc49); a template // left out of it fails the context at start. The gate says so at build time instead, with // the position of the attribute, as it does for the format's own file=. var dir = NewProject("Tpl", "tpl"); File.WriteAllText(Path.Combine(dir, "routes", "tpl.route.xml"), """ """); var result = RoutePackage.Check(dir, "tpl", "1.0.0", extensions: FileReadingContributions); result.Errors.Should().Contain(e => e.Message.Contains("'templates/order.json.sbn'") && e.Message.Contains(" e.Message.Contains("'maps/order.jsonata'") && e.Message.Contains(" """); var result = RoutePackage.Check(dir, "tplok", "1.0.0", extensions: FileReadingContributions); result.Errors.Should().BeEmpty(); } [Fact] public void AnAssemblyLocatorOrAPlaceholder_IsNotCheckedAsAPackageFile() { // assembly: ships the text inside an assembly, and {{…}} is only known once configuration // resolves it: neither can be looked for under resources/ at build time. var dir = NewProject("TplSkip", "tplskip"); File.WriteAllText(Path.Combine(dir, "routes", "tplskip.route.xml"), """ """); var result = RoutePackage.Check(dir, "tplskip", "1.0.0", extensions: FileReadingContributions); result.Errors.Should().NotContain(e => e.Message.Contains("is not under")); } [Fact] public void RegistryReferences_AreValuesStartingWithHash_NotSqlParameters() { // The sql connector writes parameters Camel-style, :#name (wave 17.6). A '#' inside the // SQL text is a parameter, not a registry reference — only a value that STARTS with '#' // (an option value, the path after the scheme, a whole attribute) references the registry. var dir = NewProject("SqlParams", "sqlparams"); File.WriteAllText(Path.Combine(dir, "routes", "sqlparams.route.xml"), """ """); var result = RoutePackage.Check(dir, "sqlparams", "1.0.0"); result.Errors.Should().BeEmpty(); result.Warnings.Should().NotContain(w => w.Message.Contains("'#login'") || w.Message.Contains("'#at'"), ":#login and :#at are sql parameters, never registry references"); result.Warnings.Should().Contain(w => w.Message.Contains("'#main-db'"), "an option value starting with '#' is still a reference"); result.Warnings.Should().Contain(w => w.Message.Contains("'#auditor'"), "the path right after bean: is still a reference"); } // ── resources outside the gate: the tool reads them where the package keeps them ── [Fact] public void ResourceRoot_OfAPackageRoute_IsTheResourcesDirectory() { // A route under /routes/ references its schemas by file name, and the package // keeps them in /resources/ - where the gate and the Tsak loader look. The // generator looked next to the route file instead (SerialNumbers.Xml, 2026-09-18). var dir = NewProject("Res"); File.WriteAllText(Path.Combine(dir, "resources", "order.xsd"), """ """); var route = Path.Combine(dir, "routes", "res.route.xml"); File.WriteAllText(route, """ """); RoutePackage.ResourceRootFor(route).Should().Be(Path.Combine(dir, "resources")); var code = XmlCodeGenerator.Generate(System.Xml.Linq.XDocument.Load(route), "ResRoutes", "Tests.Generated", sourceName: route); // Row 37: the generated code keeps the file, so its imports resolve at runtime; the generator still finds it // in resources/ (a missing one fails the generation, see Generator_NamesEveryPlaceItLooked_WhenAResourceIsMissing). code.Should().Contain("""ValidateXsdFile("order.xsd")"""); } [Fact] public void ResourceRoot_OfALooseRouteFile_IsItsOwnDirectory() { var loose = Path.Combine(_root, "loose"); Directory.CreateDirectory(loose); RoutePackage.ResourceRootFor(Path.Combine(loose, "any.route.xml")).Should().Be(loose); } [Theory] [InlineData("order.xsd")] [InlineData("resources/order.xsd")] public void Generator_And_Check_ReadAResource_TheSameWay(string reference) { // The redb-route-file template writes file="resources/order.xsd": check accepted it, the // generator prefixed resources/ again and failed on resources/resources/order.xsd. var dir = NewProject("Both"); File.WriteAllText(Path.Combine(dir, "resources", "order.xsd"), """ """); var route = Path.Combine(dir, "routes", "both.route.xml"); File.WriteAllText(route, $""" """); RoutePackage.Check(dir, "both", "1.0.0").Errors.Should().NotContain(e => e.Message.Contains("order.xsd")); new RouteProjectResourceResolver(route).Resolve(reference) .Should().Be(Path.Combine(dir, "resources", "order.xsd")); XmlCodeGenerator.Generate(System.Xml.Linq.XDocument.Load(route), "BothRoutes", "Tests.Generated", sourceName: route) .Should().Contain($"""ValidateXsdFile("{reference}")""", "the schema is found, and the generated code keeps the file"); } [Fact] public void Generator_NamesEveryPlaceItLooked_WhenAResourceIsMissing() { var dir = NewProject("Missing"); var route = Path.Combine(dir, "routes", "missing.route.xml"); File.WriteAllText(route, """ """); var act = () => XmlCodeGenerator.Generate(System.Xml.Linq.XDocument.Load(route), "MissingRoutes", "Tests.Generated", sourceName: route); act.Should().Throw() .Where(e => e.Message.Contains(Path.Combine(dir, "resources", "nothing.xsd")) && e.Message.Contains(Path.Combine(dir, "nothing.xsd"))); } // ── steps that can never run ───────────────────────────────────────────── [Fact] public void StepsAfterATerminalStep_AreFlagged_WithThePosition() { // is Camel's markRollbackOnly() now (119e76d7): it stops the route, like // ; always throws. A step written after any of them never runs. var dir = ProjectWithBean("", """ after the rollback """); var warnings = RoutePackage.Check(dir, "p", "1.0.0").Warnings.ToList(); warnings.Should().Contain(w => w.Message.Contains("") && w.Message.Contains("") && w.File.StartsWith("routes/deep.route.xml("), "the first unreachable step is named, with its position"); warnings.Should().Contain(w => w.Message.Contains("") && w.Message.Contains(""), "a branch body is a step list too"); } [Fact] public void ATerminalStepAtTheEnd_IsNotFlagged() { var dir = ProjectWithBean("", """ timed out """); RoutePackage.Check(dir, "p", "1.0.0").Warnings .Should().NotContain(w => w.Message.Contains("never runs")); } // ── the packaging gate: negatives ──────────────────────────────────────── [Fact] public void BrokenMarkup_IsABuildError_WithThePosition() { var dir = NewProject("Broken"); File.WriteAllText(Path.Combine(dir, "routes", "broken.route.xml"), """ """); var result = RoutePackage.Check(dir, "broken", "1.0.0"); result.Errors.Should().Contain(e => e.File.StartsWith("routes/broken.route.xml(") && e.Message.Contains("nosuch")); RoutePackage.Build(dir, "broken", "1.0.0", Path.Combine(_root, "out2")) .Errors.Should().NotBeEmpty("errors refuse the build"); File.Exists(Path.Combine(_root, "out2", "broken-1.0.0.tpkg")).Should().BeFalse(); } [Fact] public void MissingResource_IsABuildError() { var dir = NewProject("Res"); File.WriteAllText(Path.Combine(dir, "routes", "res.route.xml"), """ """); RoutePackage.Check(dir, "res", "1.0.0").Errors .Should().Contain(e => e.Message.Contains("schemas/missing.json") && e.Message.Contains("resources")); } [Fact] public void LiteralSecretInAUri_IsAWarning_NotSilence() { var dir = NewProject("Sec"); File.WriteAllText(Path.Combine(dir, "routes", "sec.route.xml"), """ """); var result = RoutePackage.Check(dir, "sec", "1.0.0"); result.Warnings.Should().Contain(w => w.Message.Contains("literal secret")); result.Errors.Should().BeEmpty("the heuristic warns, it does not block"); } // ── deep bean checks (a type resolver = the built assemblies at hand) ─── private static Type? TestResolver(string typeName) => Type.GetType(typeName) ?? typeof(RoutePackagingTests).Assembly.GetType(typeName.Split(',')[0].Trim()); private string ProjectWithBean(string beanXml, string beanUse = "") { var dir = NewProject("Deep" + Guid.NewGuid().ToString("N")[..6]); File.WriteAllText(Path.Combine(dir, "routes", "deep.route.xml"), $""" {beanXml} {(beanUse.Length > 0 ? beanUse : "")} """); return dir; } [Fact] public void DeepChecks_ResolveEveryTypeAttribute_WithThePosition() { // exceptions= is a comma-separated LIST of types, so an assembly-qualified name splits into // two entries and the second ('redb.Route') resolves to nothing. The gate held the built // assemblies and said nothing; the worker failed at load (SerialNumbers.Xml, 2026-09-18). var dir = ProjectWithBean("", """ """); var errors = RoutePackage.Check(dir, "p", "1.0.0", TestResolver).Errors; errors.Should().Contain(e => e.Message.Contains("'redb.Route'") && e.File.StartsWith("routes/deep.route.xml("), "every entry of a type list is resolved, and the finding carries the position"); errors.Should().Contain(e => e.Message.Contains("'No.Such.Target, Nowhere'")); errors.Should().NotContain(e => e.Message.Contains("'System.TimeoutException'")); } [Fact] public void DeepChecks_AcceptTypeListsThatResolve() { var dir = ProjectWithBean("", """ """); RoutePackage.Check(dir, "p", "1.0.0", TestResolver).Errors.Should().BeEmpty(); } [Fact] public void DeepChecks_CatchARenamedType_ANonPublicType_AndABadProperty() { var missing = ProjectWithBean(""""""); RoutePackage.Check(missing, "p", "1.0.0", TestResolver).Errors .Should().Contain(e => e.Message.Contains("was not found in the built assemblies")); var badProperty = ProjectWithBean($""" """); RoutePackage.Check(badProperty, "p", "1.0.0", TestResolver).Errors .Should().Contain(e => e.Message.Contains("no writable public property 'NoSuchProperty'")); } [Fact] public void DeepChecks_CatchAMissingBeanMethod_AndPassAGoodOne() { var bad = ProjectWithBean( $"""""", """"""); RoutePackage.Check(bad, "p", "1.0.0", TestResolver).Errors .Should().Contain(e => e.Message.Contains("no public method 'NoSuchMethod'")); var good = ProjectWithBean( $"""""", """"""); RoutePackage.Check(good, "p", "1.0.0", TestResolver).Errors.Should().BeEmpty(); } [Fact] public void WithoutAResolver_TheDeepChecksStayQuiet() { var dir = ProjectWithBean(""""""); RoutePackage.Check(dir, "p", "1.0.0").Errors .Should().NotContain(e => e.Message.Contains("built assemblies"), "without the assemblies at hand the check cannot claim the type is missing"); } // ── bean lists and references ──────────────────────────────────────────── private static string Q() => $"{typeof(TType).FullName}, x"; [Fact] public void BeanReferences_FollowTheLoadOrder_AcrossFiles() { // Route files load in manifest order (by name): a.route.xml before b.route.xml. var dir = NewProject("Refs"); File.Delete(Path.Combine(dir, "routes", "main.route.xml")); File.WriteAllText(Path.Combine(dir, "routes", "a.route.xml"), $""" """); File.WriteAllText(Path.Combine(dir, "routes", "b.route.xml"), $""" """); var result = RoutePackage.Check(dir, "refs", "1.0.0"); result.Errors.Should().ContainSingle(e => e.Message.Contains("'late' points forward")) .Which.File.Should().StartWith("routes/a.route.xml(4,"); result.Warnings.Should().Contain(w => w.Message.Contains("'external' is not declared by any "), "module code may register it — the gate cannot know"); result.Errors.Should().NotContain(e => e.Message.Contains("'early'"), "a later file may look back"); } [Fact] public void BeanGrammar_IsTheLoadersGrammar_InTheGate() { var dir = ProjectWithBean($""" """); RoutePackage.Check(dir, "p", "1.0.0").Errors .Should().Contain(e => e.Message.Contains("a bean reference is the bare name")); } [Fact] public void DeepChecks_HoldListItemsAndReferences_AgainstTheirTargets() { var dir = ProjectWithBean($""" x """); var errors = RoutePackage.Check(dir, "p", "1.0.0", TestResolver).Errors.Select(e => e.Message).ToList(); errors.Should().Contain(m => m.Contains($"'{typeof(ProbeOptions).FullName}' is not assignable to ProbePartner for 'Partners[0]'"), "a referenced bean's type is known from its declaration"); errors.Should().Contain(m => m.Contains("for 'Partners[1]'"), "a nested bean inside a list is checked too"); errors.Should().Contain(m => m.Contains("'Title' is String, which a does not build into")); errors.Should().Contain(m => m.Contains($"'{typeof(ProbeRoster).FullName}' is not assignable to ProbePartner for 'Signing'"), "a factory bean is what its method returns"); errors.Should().Contain(m => m.Contains("'constructorArg 1': a passed to a constructor names its element type with of=")); errors.Should().HaveCount(5, "the factory argument is typed by the parameter and is right"); } [Fact] public void DeepChecks_PassAWellTypedNode() { var dir = ProjectWithBean($""" {"{{"}port{"}}"} """); RoutePackage.Check(dir, "p", "1.0.0", TestResolver).Errors.Should().BeEmpty(); } [Fact] public void PlaceholderSecret_DoesNotTriggerTheWarning() { var dir = NewProject("SecOk"); File.WriteAllText(Path.Combine(dir, "routes", "sec.route.xml"), """ """); RoutePackage.Check(dir, "secok", "1.0.0").Warnings .Should().NotContain(w => w.Message.Contains("literal secret")); } [Fact] public void Aggregate_ForceCompletionOnStop_IsKnownToTheGate() { // Apache Camel forceCompletionOnStop (04edaf35): the attribute is part of the format, typed bool. string Routes(string value) => $""" batch """; var good = NewProject("AggGood"); File.WriteAllText(Path.Combine(good, "routes", "main.route.xml"), Routes("true")); var bad = NewProject("AggBad"); File.WriteAllText(Path.Combine(bad, "routes", "main.route.xml"), Routes("sometimes")); RoutePackage.Check(good, "agg", "1.0.0").Errors.Should().BeEmpty(); RoutePackage.Check(bad, "agg", "1.0.0").Errors .Should().Contain(e => e.Message.Contains("forceCompletionOnStop")); } }