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, 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));
     }));
 }
Esempio n. 4
0
 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);
 });