0
carelearning created
Hello,
What is the best way to mock this linq statement:
var results = _groupRepository
.GetAllIncluding(x => x.OrganizationUnit)
.Where(x => x.Id != id)
.ToList();
We have tried something like:
_groupRepository.Setup(x => x.GetAllIncluding(It.IsAny<Expression<Func<Group, object>>>)
.Where(It.IsAny<Expression<Func<Group, bool>>>))
.Returns(groups.AsQueryable);
This will not compiled due to " Error CS1503: Argument 1: cannot convert from 'method group' to 'Expression<Func<Group, object>>' " Is this possible?
Thanks.
3 Answer(s)
-
0
You are missing parentheses:
_groupRepository.Setup(x => x.GetAllIncluding(It.IsAny<Expression<Func<Group, object>>>()) .Where(It.IsAny<Expression<Func<Group, bool>>>())) .Returns(groups.AsQueryable);
-
0
Thank you @aaron for catching our silly mistake.
-
0
thanks for the feedback