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

Could we get some usage examples for using `CreateDBQueryMock` #22

Closed
1RedOne opened this issue Dec 12, 2019 · 2 comments
Closed

Could we get some usage examples for using `CreateDBQueryMock` #22

1RedOne opened this issue Dec 12, 2019 · 2 comments

Comments

@1RedOne
Copy link

@1RedOne 1RedOne commented Dec 12, 2019

Hi!

I am interested in this project as a way of mocking calls to a SQL View I expose as a QueryType in my project. But I can't figure out the syntax I should be using to call CreateDbQueryMock

Given this class:

public class MyClass {
    public int MyClassID {get; set;}
    public string MyClassString {get; set;}
    public string MyClassColor {get; set;}    

}

It seems like I should be able to mock this like so:

DbContextMock<MyContext> _myContext = new DbContextMock<MyContext>();

var members = new[] {
    new MyClass (){
        MyClassID =1 , MyClassString = "SomeUser", MyClassColor = "Blue"
    },
    new MyClass (){
        MyClassID =2 , MyClassString = "SomeOtherUser", MyClassColor = "Red"
    }
};

_myContext .CreateDbQueryMock<MyClass>(x=>x.MyClass, members);

But I get errors like this:

MyContext does not contain a definition for 'MyClass' and no extension method 'MyClass' acception a first argument type of 'MyContext' could be found.

Any tips?

@huysentruitw

This comment has been minimized.

Copy link
Owner

@huysentruitw huysentruitw commented Dec 15, 2019

You've sent me a pull-request, does that mean that your question has been resolved?

huysentruitw added a commit that referenced this issue Dec 15, 2019
@1RedOne

This comment has been minimized.

Copy link
Author

@1RedOne 1RedOne commented Dec 16, 2019

yes, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.