public async Task GetAllExamsFromCourseForStudent_ShouldReturnExamsForStudentWithThatId()
        {
            // Arrange
            var expectedExamsDtoList = new List <ExamDto> {
                _examDto
            };
            var course        = _exam.Course;
            var courseDtoList = new List <CourseDto> {
                CourseTestUtils.GetCourseDetailsDto(CourseTestUtils.GetCourse().Id)
            };
            var student = StudentTestUtils.GetStudent();

            _mockCourseService.Setup(service => service.GetCourseById(course.Id)).ReturnsAsync(course);
            _mockStudentCourseService.Setup(service => service.GetCourses(student.Id)).ReturnsAsync(courseDtoList);
            _mockStudentService.Setup(service => service.GetStudentById(student.Id)).ReturnsAsync(student);
            var examsList = new List <Domain.Entities.Exam> {
                ExamTestUtils.GetExam()
            };
            var mockExamsQueryable = examsList.AsQueryable().BuildMock();

            _mockReadRepository.Setup(repo => repo.GetAll <Domain.Entities.Exam>()).Returns(mockExamsQueryable);
            _mockExamMapper.Setup(mapper => mapper.Map(_exam)).Returns(_examDto);
            // Act
            var actualExamsDtoList = await _examService.GetAllExamsFromCourseForStudent(course.Id, student.Id);

            // Assert
            actualExamsDtoList.Should().BeEquivalentTo(expectedExamsDtoList);
        }
 public void Setup()
 {
     client          = new CustomWebApplicationFactory <Startup>().CreateClient();
     exam            = ExamTestUtils.GetExam();
     examDto         = ExamTestUtils.GetExamDto(exam.Id);
     examCreatingDto = ExamTestUtils.GetExamCreatingDto();
 }
예제 #3
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()
 {
     this._exam            = ExamTestUtils.GetExam();
     this._examDto         = ExamTestUtils.GetExamDto(this._exam.Id);
     this._examCreatingDto = ExamTestUtils.GetExamCreatingDto();
     this._examMapper      = new ExamMapper();
 }
        public async Task getAllExamsForACourse_ShouldReturnExamsForThatCourse()
        {
            List <ExamDto> examDtosExpected = new List <ExamDto> {
                ExamTestUtils.GetExamDto(exam.Id)
            };
            var response = await client.GetAsync("api/courses/" + CourseTestUtils.GetCourse().Id
                                                 + "/exams");

            //Assert
            response.EnsureSuccessStatusCode();
            var responseString = await response.Content.ReadAsStringAsync();

            List <ExamDto> examsDetailsDtosActual = JsonConvert.DeserializeObject <List <ExamDto> >(responseString);

            examsDetailsDtosActual.Should().BeEquivalentTo(examDtosExpected);
        }
 public void TestInitialize()
 {
     this._exam                           = ExamTestUtils.GetExam();
     this._examDto                        = ExamTestUtils.GetExamDto(_exam.Id);
     this._examCreatingDto                = ExamTestUtils.GetExamCreatingDto();
     this._mockReadRepository             = new Mock <IReadRepository>();
     this._mockWriteRepository            = new Mock <IWriteRepository>();
     this._mockCourseService              = new Mock <ICourseService>();
     this._mockExamMapper                 = new Mock <IExamMapper>();
     this._mockStudentCourseService       = new Mock <IStudentCourseService>();
     this._mockStudentService             = new Mock <IStudentService>();
     this._mockClassroomAllocationService = new Mock <IClassroomAllocationService>();
     this._mockClassroomAllocationMapper  = new Mock <IClassroomAllocationMapper>();
     this._mockStudentMapper              = new Mock <IStudentMapper>();
     this._mockGradeMapper                = new Mock <IGradeMapper>();
     this._mockEmailService               = new Mock <IEmailService>();
     _examService                         = new ExamService(_mockReadRepository.Object, _mockWriteRepository.Object,
                                                            _mockExamMapper.Object, _mockCourseService.Object,
                                                            _mockStudentCourseService.Object, _mockStudentService.Object,
                                                            _mockClassroomAllocationService.Object, _mockClassroomAllocationMapper.Object,
                                                            _mockGradeMapper.Object, _mockStudentMapper.Object, _mockEmailService.Object);
 }
예제 #7
0
        public void Map_ShouldReturnGrade_WhenArgumentsAreGradeCreationDtoStudentAndExam()
        {
            // Act
            var result = gradeMapper.Map(gradeCreationDto, StudentTestUtils.GetStudent(), ExamTestUtils.GetExam());

            // Assert
            result.Should().BeEquivalentTo(grade, options => options.Excluding(g => g.Id));
        }