Path: redb-route/tests/redb.Route.Tests.Sql/E2E/Base/ParameterSyntaxE2ETestsBase.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.Sql/E2E/Base/ParameterSyntaxE2ETestsBase.cs
----
using redb.Route.Core;
using redb.Route.Tests.Sql.E2E.Infrastructure;
namespace redb.Route.Tests.Sql.E2E.Base;
///
/// On a real server, :#name is the only placeholder: an @ inside a string literal reaches the table as written.
///
public abstract class ParameterSyntaxE2ETestsBase : IAsyncLifetime
{
private SqlE2EDatabase? _db;
/// The provider under test.
protected abstract SqlE2EProvider Provider { get; }
/// The database of the test, created in .
protected SqlE2EDatabase Db => _db ?? throw new InvalidOperationException("The table is created in InitializeAsync.");
///
public async Task InitializeAsync() => _db = await SqlE2EDatabase.CreateAsync(Provider);
///
public async Task DisposeAsync()
{
try
{
if (_db is not null)
await _db.DisposeAsync();
}
finally
{
(Provider as IDisposable)?.Dispose();
}
}
[Fact]
public async Task LiteralContainingAt_PersistedAsWritten()
{
await using var context = new RouteContext();
var endpoint = SqlEndpointHarness.CreateEndpoint(context, Db.CreateConnectionFactory(),
$"INSERT INTO {Db.Table} (id, val) VALUES (:#id, 'user@example.com')", new() { ["outputType"] = "None" });
var exchange = new Exchange(new Message());
exchange.In.Headers["id"] = 5;
var thrown = await Outcome.Of(() => endpoint.CreateProducer().Process(exchange, CancellationToken.None));
thrown.Should().BeNull(Outcome.Describe(thrown));
var rows = await Db.QueryAsync($"SELECT id, val FROM {Db.Table}");
rows.Should().ContainSingle();
Convert.ToInt32(rows[0][0]).Should().Be(5);
rows[0][1].Should().Be("user@example.com");
}
}