public async Task GetCheckedInStudent_ShouldReturnStudentsThatCheckedInAtExam() { // Arrange Grade grade = GradeTestUtils.GetInitialStateGrade(); var grades = new List <Grade> { grade }; GradeDto gradeDto = GradeTestUtils.GetInitialGradeDto(grade.Id); Student student = StudentTestUtils.GetStudent(); _mockReadRepository.Setup(repo => repo.GetByIdAsync <Domain.Entities.Exam>(_exam.Id)).ReturnsAsync(_exam); _mockReadRepository.Setup(repo => repo.GetAll <Grade>()).Returns(grades.AsQueryable().BuildMock); _mockGradeMapper.Setup(mapper => mapper.Map(grade)).Returns(gradeDto); _mockStudentMapper.Setup(mapper => mapper.Map(student, gradeDto)) .Returns(StudentTestUtils.GetStudentFetchingGradeDto(student.Id, gradeDto)); var expectedResult = new List <StudentFetchingGradeDto> { StudentTestUtils.GetStudentFetchingGradeDto(student.Id, gradeDto) }; // Act var result = await _examService.GetCheckedInStudents(_exam.Id); // Assert result.Should().BeEquivalentTo(expectedResult); }
public void Map_ShouldReturnStudentFetchingGradeDto_WhenArgumentsAreStudentAndGradeDto() { // Arrange var gradeDto = GradeTestUtils.GetInitialGradeDto(Guid.NewGuid()); // Act var result = _studentMapper.Map(_student, gradeDto); // Assert result.Should().BeEquivalentTo(StudentTestUtils.GetStudentFetchingGradeDto(_student.Id, gradeDto)); }
public async Task GetCheckedInStudent_ShouldReturnAllStudentThatCheckedInAtExam() { // Arrange var expectedStudents = new List <StudentFetchingGradeDto> { StudentTestUtils.GetStudentFetchingGradeDto(StudentTestUtils.GetStudent().Id, GradeTestUtils.GetInitialGradeDto(GradeTestUtils.GetInitialStateGrade().Id)), StudentTestUtils.GetStudentFetchingGradeDto(StudentTestUtils.GetStudent2().Id, GradeTestUtils.GetGradeWithValueDto(GradeTestUtils.GetGradeWithValue().Id, GradeTestUtils.GetGradeWithValue().Date)) }; // Act var response = await client.GetAsync("api/exams/" + exam.Id + "/checked-in-students"); // Assert response.EnsureSuccessStatusCode(); var responseString = await response.Content.ReadAsStringAsync(); List <StudentFetchingGradeDto> actualStudents = JsonConvert.DeserializeObject <List <StudentFetchingGradeDto> >(responseString); actualStudents.Should().BeEquivalentTo(expectedStudents, options => options.Excluding(s => s.Grade.Date)); }