static ISetup <DbConnection, Task <TResult> > SetupQueryAsync <TResult>(Mock <DbConnection> mock) => DbCommandSetup.SetupCommandAsync <TResult, DbConnection>(mock, (commandMock, result) => { commandMock.Protected() .Setup <Task <DbDataReader> >("ExecuteDbDataReaderAsync", ItExpr.IsAny <CommandBehavior>(), ItExpr.IsAny <CancellationToken>()) .ReturnsAsync(() => DbDataReaderFactory.DbDataReader(result)); });
private static ISetup <TConnection, int> SetupExecute <TConnection>(Mock <TConnection> mock) where TConnection : class, IDbConnection { return(DbCommandSetup.SetupCommand <int, TConnection>( mock, (commandMock, result) => { commandMock .Setup(command => command.ExecuteNonQuery()) .Returns(() => result()); })); }
private static ISetup <TConnection, TResult> SetupExecuteScalar <TResult, TConnection>(Mock <TConnection> mock) where TConnection : class, IDbConnection { return(DbCommandSetup.SetupCommand <TResult, TConnection>( mock, (commandMock, result) => { commandMock .Setup(command => command.ExecuteScalar()) .Returns(() => result()); })); }
private static ISetup <TConnection, TResult> SetupQuery <TResult, TConnection>(Mock <TConnection> mock) where TConnection : class, IDbConnection { return(DbCommandSetup.SetupCommand <TResult, TConnection>( mock, (commandMock, result) => { commandMock .Setup(command => command.ExecuteReader(It.IsAny <CommandBehavior>())) .Returns(() => DbDataReaderProvider.DbDataReader(result)); })); }
private static ISetup <TConnection, Task <TResult> > SetupExecuteScalarAsync <TResult, TConnection>(Mock <TConnection> mock) where TConnection : class, IDbConnection { return(DbCommandSetup.SetupCommandAsync <TResult, TConnection>( mock, (commandMock, result) => { commandMock .Setup(command => command.ExecuteScalarAsync(It.IsAny <CancellationToken>())) .ReturnsAsync(result); })); }
private static ISetup <TConnection, Task <TResult> > SetupQueryAsync <TResult, TConnection>(Mock <TConnection> mock) where TConnection : class, IDbConnection { return(DbCommandSetup.SetupCommandAsync <TResult, TConnection>( mock, (commandMock, result) => { commandMock .Protected() .Setup <Task <DbDataReader> >( "ExecuteDbDataReaderAsync", ItExpr.IsAny <CommandBehavior>(), ItExpr.IsAny <CancellationToken>()) .ReturnsAsync(() => DbDataReaderProvider.DbDataReader(result)); })); }
static ISetup <IDbConnection, Task <object> > SetupExecuteScalarAsync(Mock <IDbConnection> mock) => DbCommandSetup.SetupExecuteScalarCommandAsync(mock, (commandMock, result) => { commandMock.Setup(x => x.ExecuteScalarAsync(It.IsAny <CancellationToken>())).ReturnsAsync(result); });
static ISetup <IDbConnection, Task <int> > SetupExecuteAsync(Mock <IDbConnection> mock) => DbCommandSetup.SetupCommandAsync <int, IDbConnection>(mock, (commandMock, result) => { commandMock.Setup(command => command.ExecuteNonQueryAsync(It.IsAny <CancellationToken>())) .ReturnsAsync(result); });