Path: redb-route/tests/redb.Route.Tests.Xml/SpanTagXmlTests.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/SpanTagXmlTests.cs
----
using System.Diagnostics;
using AwesomeAssertions;
using redb.Route.Abstractions;
using redb.Route.Core;
using redb.Route.Definitions;
using redb.Route.Expressions;
using redb.Route.Telemetry;
using redb.Route.Xml;
namespace redb.Route.Tests.Xml;
///
/// <spanTag>, the markup form of .SpanTag(key, value, target). Shaped as <setHeader>:
/// value is a literal and expr an expression, exactly one of them; target picks the span. The
/// definition it builds and the C# it prints are checked here; what lands on which span is covered by the engine's
/// own SpanTagTests.
///
public class SpanTagXmlTests : IAsyncLifetime
{
private readonly RouteContext _context = new();
public Task InitializeAsync() => Task.CompletedTask;
public async Task DisposeAsync()
{
await _context.DisposeAsync();
GC.SuppressFinalize(this);
}
private SpanTagDefinition[] TagsOf(string xml)
{
_context.AddXmlRoutesFromContent(xml, "");
var builder = _context.RouteBuilders.Single();
if (!builder.IsBuilt)
builder.InternalBuild(_context);
return builder.Definitions.Single().Outputs.OfType().ToArray();
}
private static string CodeOf(string xml)
=> XmlCodeGenerator.Generate(System.Xml.Linq.XDocument.Parse(xml), "Tags", "Tests.Generated",
sourceName: "");
[Fact]
public void Value_IsALiteral_AndTheTargetDefaultsToTheEnclosingSpan()
{
var tag = TagsOf("""
""").Single();
tag.Key.Should().Be("flow.name");
tag.Target.Should().Be(SpanTarget.Enclosing);
tag.Value.Should().BeOfType("value is a literal, as on ")
.Which.Evaluate