Here are the examples of the csharp api Moq.Dapper.DbConnectionMockExtensions.SetupExecuteScalarAsync(Moq.Mock) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
19
Source : DbConnectionMockExtensions.cs
with GNU General Public License v2.0
from UnoSD
with GNU General Public License v2.0
from UnoSD
public static ISetup<DbConnection, Task<TResult>> SetupDapperAsync<TResult>(this Mock<DbConnection> mock, Expression<Func<DbConnection, Task<TResult>>> expression)
{
var call = expression.Body as MethodCallExpression;
if (call?.Method.DeclaringType != typeof(SqlMapper))
throw new ArgumentException("Not a Dapper method.");
switch (call.Method.Name)
{
case nameof(SqlMapper.QueryAsync):
case nameof(SqlMapper.QueryFirstAsync):
case nameof(SqlMapper.QueryFirstOrDefaultAsync):
case nameof(SqlMapper.QuerySingleAsync):
case nameof(SqlMapper.QuerySingleOrDefaultAsync):
return SetupQueryAsync<TResult>(mock);
case nameof(SqlMapper.ExecuteAsync) when typeof(TResult) == typeof(int):
return (ISetup<DbConnection, Task<TResult>>)SetupExecuteAsync(mock);
case nameof(SqlMapper.ExecuteScalarAsync):
return SetupExecuteScalarAsync<TResult>(mock);
default:
throw new NotSupportedException();
}
}