Path: redb-route/tests/redb.Route.Tests.Sql/E2E/Infrastructure/SqlEndpointHarness.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/Infrastructure/SqlEndpointHarness.cs
----
using redb.Route.Abstractions;
using redb.Route.Core;
using redb.Route.Sql;
using redb.Route.Sql.Connection;
namespace redb.Route.Tests.Sql.E2E.Infrastructure;
///
/// Builds a sql: endpoint the production way: component registered on a route context, connection factory
/// in the context registry, options bound from URI parameters.
///
public static class SqlEndpointHarness
{
/// Registry name of the data source.
public const string DataSourceName = "e2e";
/// Creates an Execute-mode endpoint for with extra URI parameters.
public static SqlEndpoint CreateEndpoint(
RouteContext context, ISqlConnectionFactory factory, string sql, Dictionary? extraParameters = null)
{
var component = new SqlComponent();
context.AddComponent(component);
context.AddToRegistry(DataSourceName, factory);
var parameters = new Dictionary
{
["mode"] = "Execute",
["dataSource"] = DataSourceName,
};
if (extraParameters is not null)
foreach (var (key, value) in extraParameters)
parameters[key] = value;
var uri = new EndpointUri("sql", sql, $"sql:{sql}", parameters);
return (SqlEndpoint)component.CreateEndpoint(uri);
}
}