public void Cleanup()
 {
     this._exam            = null;
     this._examDto         = null;
     this._examCreatingDto = null;
     this._examMapper      = null;
 }
 public void Setup()
 {
     client          = new CustomWebApplicationFactory <Startup>().CreateClient();
     exam            = ExamTestUtils.GetExam();
     examDto         = ExamTestUtils.GetExamDto(exam.Id);
     examCreatingDto = ExamTestUtils.GetExamCreatingDto();
 }
 public void Setup()
 {
     this._exam            = ExamTestUtils.GetExam();
     this._examDto         = ExamTestUtils.GetExamDto(this._exam.Id);
     this._examCreatingDto = ExamTestUtils.GetExamCreatingDto();
     this._examMapper      = new ExamMapper();
 }
        public List <ClassroomAllocationCreatingDto> Map(ExamCreatingDto examCreatingDto, Guid examId)
        {
            var classroomAllocations = new List <ClassroomAllocationCreatingDto>();

            examCreatingDto.Classrooms.ForEach(classroom => classroomAllocations.Add(new ClassroomAllocationCreatingDto
            {
                ClassroomId = classroom,
                ExamId      = examId
            }));
            return(classroomAllocations);
        }
Exemple #5
0
        public async Task <IActionResult> CreateExam([FromBody] ExamCreatingDto examCreatingDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var exam = await examService.Create(examCreatingDto);

                return(CreatedAtRoute("FindExamById", new { id = exam.Id }, exam));
            }
            catch (CourseNotFoundException courseNotFoundException)
            {
                return(NotFound(courseNotFoundException.Message));
            }
        }
Exemple #6
0
        public async Task <ExamDto> Create(ExamCreatingDto examCreatingDto)
        {
            var course = await courseService.GetCourseById(examCreatingDto.CourseId);

            Domain.Entities.Exam exam = examMapper.Map(examCreatingDto, course);
            await writeRepository.AddNewAsync(exam);

            await writeRepository.SaveAsync();

            var classroomAllocations = classroomAllocationMapper.Map(examCreatingDto, exam.Id);

            foreach (var ca in classroomAllocations)
            {
                await classroomAllocationService.Create(ca);
            }
            await this.SendExamCreatedEmail(exam.Id);

            return(examMapper.Map(exam));
        }
 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);
 }
 public Domain.Entities.Exam Map(ExamCreatingDto examCreatingDto, Domain.Entities.Course course)
 {
     return(new Domain.Entities.Exam(examCreatingDto.Date, course));
 }