UnoSD / Moq.Dapper

Moq extensions for Dapper methods.
GNU General Public License v2.0
173 stars 78 forks source link

No Support for ExecuteAsync on IDBConnection #86

Closed ajaysoni-cap closed 1 year ago

ajaysoni-cap commented 1 year ago

I am trying to set up a mock for the ExecuteAsync method on the IDBConnection and getting a method not supported exception.

Here is an example,

public ApplicationRepositoryTests()
{
    var connection = new Mock<IDbConnection>();

    connection.SetupDapperAsync(dapper => dapper.ExecuteAsync(It.IsAny<string>(), It.IsAny<object>(), It.IsAny<IDbTransaction>(), It.IsAny<int?>(), It.IsAny<CommandType?>())).Returns(Task.FromResult(0));

    var repository = new ApplicationRepository(Mock.Of<IConfiguration>(), Mock.Of<IHostEnvironment>(), connection.Object);
}

Exception: System.NotSupportedException: Specified method is not supported.

Any suggestions or workaround to set this up properly, please?