I have a course repository as follows in the Arrange
A.CallTo(
() => _courseClientStatusRepository.GetTnCoursesForClientStatus()).Returns(new List<CourseClientStatusCreationDto>
{
new CourseClientStatusCreationDto { CourseTnId = Enums.CourseLevel.Beginner },
new CourseClientStatusCreationDto { CourseTnId = Enums.CourseLevel.Intermediate, },
new CourseClientStatusCreationDto { CourseTnId = Enums.CourseLevel.Advanced, }
}
);
In the Act I have a method that calls the
void CreateClientCourseStatus(List<CourseClientStatusDto> courseClientStatusDto);
method of the ICourseClientStatusRepository
and in the Assert, I have the following. The first assert passes, the second and third asserts fail.
A.CallTo(
() => _courseClientStatusRepository.CreateClientCourseStatus(A<List<CourseClientStatusDto>>.Ignored))
.MustHaveHappened();
A.CallTo(
() => _courseClientStatusRepository.CreateClientCourseStatus(A<List<CourseClientStatusDto>>.That.Contains(A<CourseClientStatusDto>.Ignored)))
.MustHaveHappened();
A.CallTo(
() => _courseClientStatusRepository.CreateClientCourseStatus(A<List<CourseClientStatusDto>>.That.Contains(A<CourseClientStatusDto>.That.Matches(
x => x.CourseTnId == Enums.CourseLevel.Beginner
))))
.MustHaveHappened();
I am at least expecting the second assert to pass at it's expecting an instance of an object of type CourseClientStatusDto , where its specific values are not important, hence i used the .Ignored property.
Is there perhaps something that i'm doing wrong to assert if a collection contains a specific object (using fake it easy .mustHaveHappened() method) ?