Path: redb-route/tests/redb.Route.Tests.Sql/E2E/Infrastructure/SqlBatchRun.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/SqlBatchRun.cs ---- using System.Collections; using redb.Route.Core; namespace redb.Route.Tests.Sql.E2E.Infrastructure; /// Runs the connector's batch once against an E2E table and captures the outcome for assertions. public static class SqlBatchRun { /// Produces through a fresh Execute endpoint; returns the exchange and what it threw. public static async Task<(Exchange Exchange, Exception? Thrown)> RunAsync( SqlE2EDatabase database, string sql, IList items, bool? breakOnError, int batchSize = 10, Dictionary? extraParameters = null) { var parameters = new Dictionary { ["outputType"] = "None", ["batchSize"] = batchSize.ToString(), }; if (breakOnError is { } mode) parameters["breakBatchOnError"] = mode ? "true" : "false"; if (extraParameters is not null) foreach (var (key, value) in extraParameters) parameters[key] = value; await using var context = new RouteContext(); var endpoint = SqlEndpointHarness.CreateEndpoint(context, database.CreateConnectionFactory(), sql, parameters); var producer = endpoint.CreateProducer(); var exchange = new Exchange(new Message(items)); var thrown = await Outcome.Of(() => producer.Process(exchange, CancellationToken.None)); return (exchange, thrown); } /// /// Indexes carried by the redbSql.batchErrors header, read by reflection so the tests compile against code that /// does not have the header's element type yet. /// public static IReadOnlyList BatchErrorIndexes(Exchange exchange) { if (!exchange.In.Headers.TryGetValue("redbSql.batchErrors", out var header) || header is not IEnumerable errors) return []; return errors.Cast() .Select(e => Convert.ToInt32(e.GetType().GetProperty("Index")?.GetValue(e))) .ToList(); } }