how to mock expression 3cfunc 3ct 3e 3e parameter

Solutions on MaxInterview for how to mock expression 3cfunc 3ct 3e 3e parameter by the best coders in the world

showing results for - "how to mock expression 3cfunc 3ct 3e 3e parameter"
Emery
01 Jul 2017
1    var fakeLessonList = new List<Lesson>
2    {
3        new Lesson() { LessonId = 1, LessonTypeId = 1,LanguageId = 1, TeacherId = 1, LessonName = "Professional Lesson"},
4        new Lesson() { LessonId = 2,LessonTypeId = 2, LanguageId = 2, TeacherId = 2, LessonName = "Professional Lesson"}
5    }.AsQueryable(); // .BuildMock(); - no mock, just a real list
6
7    _mockUnitOfWork.Setup(uow => uow.Repository<Lesson>().GetEntities(It.IsAny<Expression<Func<Lesson, bool>>>(),
8        It.IsAny<Func<IQueryable<Lesson>, IIncludableQueryable<Lesson, object>>>()))
9            .Returns(
10                (Expression<Func<Lesson, bool>> condition,
11                 Func<IQueryable<Lesson>, IIncludableQueryable<Lesson, object>> include) =>
12                // Run the queries against the list
13                // Need to add some checks in case any of those are null
14                fakeLessonList.Where(condition)
15            );
16
similar questions