Path: redb-route/tests/redb.Route.Tests.Sql/Batch/Fakes/FixedConnectionFactory.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/Batch/Fakes/FixedConnectionFactory.cs
----
using System.Data.Common;
using redb.Route.Sql.Connection;
namespace redb.Route.Tests.Sql.Batch.Fakes;
/// Hands out one prepared connection instance and counts the requests.
internal sealed class FixedConnectionFactory(DbConnection connection) : ISqlConnectionFactory
{
/// How many times a connection was requested.
public int Requests { get; private set; }
public Task CreateConnectionAsync(bool readOnly = false, CancellationToken ct = default)
{
Requests++;
return Task.FromResult(connection);
}
}