Code Monkey home page Code Monkey logo

Comments (4)

DavidKorn avatar DavidKorn commented on May 24, 2024

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 ?

from moq.dapper.

UnoSD avatar UnoSD commented on May 24, 2024

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

from moq.dapper.

rogeryamato avatar rogeryamato commented on May 24, 2024

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

from moq.dapper.

mcalvinsf avatar mcalvinsf commented on May 24, 2024

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.

from moq.dapper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.