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

Mocking "FindBy" with Generic Repository C# .Net #301

Closed
marioguadanhim opened this issue Nov 24, 2016 · 1 comment
Closed

Mocking "FindBy" with Generic Repository C# .Net #301

marioguadanhim opened this issue Nov 24, 2016 · 1 comment

Comments

@marioguadanhim
Copy link

Hi guys,

Recently I started to test my solution with mocks and i got the following issue.
I'm using the "Repository" parttern, but i can not create a mock to it.
Example:

private IRepository myClassRepository;

public void Test()
{
List arrMyClass = LoadArrayMyClassWithObjects();

 myClass = new Moq <IRepository<MyClass>>();

myClass.Setup(x => x.findby(myclass => myclass.id ==1 ).ToList() ).Return(arrMyClass); 

}

What is the correct code to write the method above? In my test, it's returning a null error.

Thanks.

@kzu
Copy link
Contributor

kzu commented Nov 25, 2016

Delete .ToList()

@kzu kzu closed this as completed Nov 25, 2016
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

2 participants