UnoSD / Moq.Dapper

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

QueryAsync returns no records #91

Open molynerd opened 1 year ago

molynerd commented 1 year ago

Either I've configured something incorrectly, or QueryAsync doesn't work.

public class SomethingToMock
{
    private string Key;

    public SomethingToMock(string key)
    {
        Key = key;
    }
}

[Fact]
public async Task DoesMoqDapperWork()
{
    var connection = new Mock<IDbConnection>();

    var expected = new[]
    {
        new SomethingToMock ("asdf")
    };

    connection.SetupDapperAsync(c => c.QueryAsync<SomethingToMock>(It.IsAny<string>(), null, null, null, null))
        .ReturnsAsync(expected);

    var data = await connection.Object.QueryAsync<SomethingToMock>("foo");
    Assert.Equal(expected.Length, data.Count());
}