Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for dynamic methods #23

Open
UnoSD opened this issue Jun 25, 2018 · 4 comments
Open

Support for dynamic methods #23

UnoSD opened this issue Jun 25, 2018 · 4 comments

Comments

@UnoSD
Copy link
Owner

UnoSD commented Jun 25, 2018

See #22

@DavidKorn
Copy link

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 ?

@UnoSD
Copy link
Owner Author

UnoSD commented Jul 24, 2018

@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.

@rogeryamato
Copy link

So @UnoSD what's the status now? Can I use dynamic for UT?

@mcalvinsf
Copy link

mcalvinsf commented Jul 18, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants