Пример #1
0
        public static async System.Threading.Tasks.Task PopulateTestDatabaseAsync(ExamContext examContext)
        {
            Student student = StudentTestUtils.GetStudent();
            Course  course  = CourseTestUtils.GetCourse();
            await examContext.AddNewAsync(student);

            await examContext.AddNewAsync(StudentTestUtils.GetStudent2());

            await examContext.AddNewAsync(course);

            await examContext.AddNewAsync(CourseTestUtils.GetCourse2());

            await examContext.AddNewAsync(ProfessorTestUtils.GetProfessor());

            await examContext.AddNewAsync(ProfessorTestUtils.GetProfessor2());

            await examContext.AddNewAsync(StudentCourseTestUtils.GetStudentCourse(student.Id, course.Id));

            await examContext.AddNewAsync(ExamTestUtils.GetExam());

            await examContext.AddNewAsync(ClassroomTestUtils.GetClassroom());

            await examContext.AddNewAsync(GradeTestUtils.GetInitialStateGrade());

            await examContext.AddNewAsync(ClassroomAllocationTestUtils.GetClassroomAllocation());

            await examContext.AddNewAsync(GradeTestUtils.GetGradeWithValue());

            await examContext.SaveAsync();
        }
 public void Setup()
 {
     client                   = new CustomWebApplicationFactory <Startup>().CreateClient();
     student1                 = StudentTestUtils.GetStudent();
     student2                 = StudentTestUtils.GetStudent2();
     studentDetailsDto1       = StudentTestUtils.GetStudentDetailsDto(student1.Id);
     studentDetailsDto2       = StudentTestUtils.GetStudentDetailsDto(student2.Id);
     studentCreationDto       = StudentTestUtils.GetStudentCreationDto();
     course1                  = CourseTestUtils.GetCourse();
     course2                  = CourseTestUtils.GetCourse2();
     courseDetailsDto         = CourseTestUtils.GetCourseDetailsDto(course1.Id);
     studentCourseCreationDto = StudentCourseTestUtils.GetStudentCourseCreationDto(course2.Id);
 }
        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));
        }