Reputation: 1262
I have a following class called TestClass and has one function.
In TestClass
public virtual async Task<IEnumerable<T>> GetAll(Expression<Func<T, bool>> predicate, params Expression<Func<T, object>>[] includes)
This is How I am trying to mock the method above using NSubstitute.
_testClass.GetAll(Arg.Any<Expression<Func<Animal, bool>>>()).Returns(new List<Animal>(){new Animal(), new Animal()});
it complies fine but the mocked method when called does not include the two Animal object in the collection because collection length is zero. I have a feeling since I am not mocking the params part as well thats why this issue is happening. Any one know how to properly mock it?
Upvotes: 1
Views: 790
Reputation: 1262
Cracked it.
Following is how you should do it.
test.GetAll(Arg.Any<Expression<Func<Animal, bool>>>(),Arg.Any<Expression<Func<Animal,object>>>())
.Returns(new List<Animal>(){new Animal(), new Animal()});
Upvotes: 0