Hi,
the example with object in ExecuteScalarAsync generic works well (xUnit version)
[Fact()]
public async Task ExecuteScalarAsyncTest()
{
var connection = new Mock<DbConnection>();
const string expected = "Hello";
connection.SetupDapperAsync(c => c.ExecuteScalarAsync<object>(It.IsAny<string>(), null, null, null, null))
.ReturnsAsync(expected);
var actual = await connection.Object.ExecuteScalarAsync<object>("");
Assert.Equal(actual, expected);
}
but when I change object to desired specific type, e.g. string the test throws exception in SetupDapperAsyncMethod
[Fact()]
public async Task ExecuteScalarAsyncTest()
{
var connection = new Mock<DbConnection>();
const string expected = "Hello";
connection.SetupDapperAsync(c => c.ExecuteScalarAsync<string>(It.IsAny<string>(), null, null, null, null))
.ReturnsAsync(expected);
var actual = await connection.Object.ExecuteScalarAsync<string>("");
Assert.Equal(actual, expected);
}
with followed message
Message:
System.InvalidCastException : Unable to cast object of type 'Castle.Proxies.ISetup`2Proxy' to type 'Moq.Language.Flow.ISetup`2[System.Data.Common.DbConnection,System.Threading.Tasks.Task`1[System.String]]'.
Stack Trace:
DbConnectionMockExtensions.SetupDapperAsync[TResult](Mock`1 mock, Expression`1 expression)
Hi, the example with
object
inExecuteScalarAsync
generic works well (xUnit version)but when I change
object
to desired specific type, e.g.string
the test throws exception inSetupDapperAsyncMethod
with followed message