Path: redb-route/tests/redb.Route.Tests.Xml/UnclosedPlaceholderTests.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/UnclosedPlaceholderTests.cs ---- using AwesomeAssertions; using redb.Route.Core; using redb.Route.Xml; using redb.Route.Xml.Packaging; namespace redb.Route.Tests.Xml; /// /// An unclosed ${ is an error (owner decision 2026-11-05): a route file fails to load at the element, and the /// package gate reports it at the attribute, in every place that holds an expression or an address. /// public sealed class UnclosedPlaceholderTests : IAsyncLifetime, IDisposable { private readonly RouteContext _context = new(); private readonly string _root = Path.Combine(Path.GetTempPath(), "redb-xml-unclosed-" + Guid.NewGuid().ToString("N")); public UnclosedPlaceholderTests() => Directory.CreateDirectory(_root); public Task InitializeAsync() => Task.CompletedTask; public async Task DisposeAsync() => await _context.DisposeAsync(); public void Dispose() => Directory.Delete(_root, recursive: true); private static Type? Resolve(string typeName) => Type.GetType(typeName); private string Project(string steps) { var dir = RouteProjectScaffold.Create(_root, "Unclosed" + Guid.NewGuid().ToString("N")[..6]); File.WriteAllText(Path.Combine(dir, "routes", "main.route.xml"), $""" {steps} """); return dir; } [Fact] public void Load_FailsAtTheElement_WithThePosition() { var act = () => _context.AddXmlRoutesFromContent(""" """); act.Should().Throw() .WithMessage("*(4,*unclosed '${' at position 7 of \"total ${header.amount\": the placeholder has no closing '}'.*"); } [Theory] [InlineData("""""", "expr=")] [InlineData("""""", "expr=")] [InlineData("""""", "uri=")] [InlineData("""""", "message=")] public void Gate_ReportsAnError_AtTheAttribute(string step, string attribute) { var errors = RoutePackage.Check(Project(step), "p", "1.0.0", Resolve).Errors.ToList(); errors.Should().Contain(e => e.Message.StartsWith(attribute + " unclosed '${'", StringComparison.Ordinal) && e.File.Contains("main.route.xml(")); } [Fact] public void Gate_ReportsTheFromAddress() { var dir = RouteProjectScaffold.Create(_root, "UnclosedFrom"); File.WriteAllText(Path.Combine(dir, "routes", "main.route.xml"), """ """); RoutePackage.Check(dir, "p", "1.0.0", Resolve).Errors .Should().Contain(e => e.Message.StartsWith("uri= unclosed '${'", StringComparison.Ordinal)); } [Theory] [InlineData("""""")] [InlineData("""""")] [InlineData("""""")] [InlineData("""""")] public void Gate_LeavesLiteralsAndClosedPlaceholdersAlone(string step) { RoutePackage.Check(Project(step), "p", "1.0.0", Resolve).Errors .Should().NotContain(e => e.Message.Contains("unclosed '${'", StringComparison.Ordinal)); } }