Path: redb-route/tests/redb.Route.Tests.Sql/Batch/Fakes/FakeBatchCommand.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/FakeBatchCommand.cs ---- using System.Data; using System.Data.Common; using System.Diagnostics.CodeAnalysis; using Microsoft.Data.Sqlite; namespace redb.Route.Tests.Sql.Batch.Fakes; /// /// Command of : executions go to the connection's script. Parameters live in a real /// SQLite parameter collection, so the connector's binding code runs unchanged. /// internal sealed class FakeBatchCommand : DbCommand { private readonly FakeBatchConnection _connection; private readonly SqliteCommand _parameterHost = new(); private string _commandText = ""; public FakeBatchCommand(FakeBatchConnection connection) { _connection = connection; DbConnection = connection; } [AllowNull] public override string CommandText { get => _commandText; set => _commandText = value ?? ""; } public override int CommandTimeout { get; set; } public override CommandType CommandType { get; set; } public override bool DesignTimeVisible { get; set; } public override UpdateRowSource UpdatedRowSource { get; set; } protected override DbConnection? DbConnection { get; set; } protected override DbParameterCollection DbParameterCollection => _parameterHost.Parameters; protected override DbTransaction? DbTransaction { get; set; } public override void Cancel() { } public override void Prepare() { } public override int ExecuteNonQuery() => _connection.Execute(CommandText, CancellationToken.None); public override Task ExecuteNonQueryAsync(CancellationToken cancellationToken) { try { return Task.FromResult(_connection.Execute(CommandText, cancellationToken)); } catch (Exception ex) { // Surface the scripted failure the way an async provider does: through the task. return Task.FromException(ex); } } public override object? ExecuteScalar() => _connection.Execute(CommandText, CancellationToken.None); protected override DbParameter CreateDbParameter() => new SqliteParameter(); protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) => throw new NotSupportedException("The fake batch connection only executes non-queries."); protected override void Dispose(bool disposing) { if (disposing) _parameterHost.Dispose(); base.Dispose(disposing); } }