Open UnoSD opened 6 years ago
We need dynamic method support too, so I'm thinking of forking and adding it, but before I do I wanted to make sure nobody else was already about to release this. Are you actively working on it @UnoSD ?
@DavidKorn not at the moment, I had some spare time and I went through the issues from the oldest, I'll be happy to review when I get a chance if you want to contribute.
So @UnoSD what's the status now? Can I use dynamic for UT?
I also cannot get mocking QueryAsync to work with my own types either. Is there any similar solution yet ?
I have tried something like the following ...
` [Fact]
public async Task QueryAsyncGeneric()
{
var connection = new Mock
var expected = new List<ObjectTypeOperation>()
{
new ObjectTypeOperation(ObjectTypes.DataDictionary, Operation.ManageData),
new ObjectTypeOperation(ObjectTypes.Account, Operation.View)
};
SetupToReturn(connection, expected);
var actual = (await connection.Object.QueryAsync<ObjectTypeOperation>("", null, null, null, null )).ToList();
}
private void SetupToReturn<T>(Mock<DbConnection> conn, IEnumerable<T> results)
{
conn
.SetupDapperAsync(mc => mc.QueryAsync<T>(It.IsAny<string>(), It.IsAny<object>(), null, null, It.IsAny<CommandType>()))
.ReturnsAsync(results);
}
I found that the issues lies in the fact that ObjectTypeOperation has enum properties. So apparently Moq.Dapper does not currently support this. When I changed the properties to int the test works.
See #22