Ejemplo n.º 1
0
 public void Cleanup()
 {
     this._course            = null;
     this._courseDetailsDto  = null;
     this._courseCreatingDto = null;
     this._courseMapper      = null;
 }
Ejemplo n.º 2
0
 public void Setup()
 {
     this._course            = CourseTestUtils.GetCourse();
     this._courseDetailsDto  = CourseTestUtils.GetCourseDetailsDto(this._course.Id);
     this._courseCreatingDto = CourseTestUtils.GetCourseCreatingDto();
     this._courseMapper      = new CourseMapper();
 }
Ejemplo n.º 3
0
 public void Setup()
 {
     client            = new CustomWebApplicationFactory <Startup>().CreateClient();
     course1           = CourseTestUtils.GetCourse();
     course2           = CourseTestUtils.GetCourse2();
     courseDetailsDto1 = CourseTestUtils.GetCourseDetailsDto(course1.Id);
     courseDetailsDto2 = CourseTestUtils.GetCourseDetailsDto(course2.Id);
     courseCreationDto = CourseTestUtils.GetCourseCreatingDto();
 }
 public void TestInitialize()
 {
     this._course1             = CourseTestUtils.GetCourse();
     this._course2             = CourseTestUtils.GetCourse();
     this._courseDto1          = CourseTestUtils.GetCourseDetailsDto(_course1.Id);
     this._courseDto2          = CourseTestUtils.GetCourseDetailsDto(_course2.Id);
     this._courseCreatingDto   = CourseTestUtils.GetCourseCreatingDto();
     this._mockReadRepository  = new Mock <IReadRepository>();
     this._mockWriteRepository = new Mock <IWriteRepository>();
     this._mockCourseMapper    = new Mock <ICourseMapper>();
     _mockProfessorService     = new Mock <IProfessorService>();
     _mockStudentService       = new Mock <IStudentService>();
     _courseService            = new CourseService(_mockReadRepository.Object, _mockWriteRepository.Object,
                                                   _mockCourseMapper.Object, _mockProfessorService.Object, _mockStudentService.Object);
 }
Ejemplo n.º 5
0
        public async Task <IActionResult> Update(Guid courseId, [FromBody] CourseCreatingDto courseCreatingDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var existingCourse = await this.courseService.Update(courseId, courseCreatingDto);

                return(NoContent());
            }
            catch (CourseNotFoundException courseNotFoundException)
            {
                return(NotFound(courseNotFoundException.Message));
            }
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Create(Guid professorId, [FromBody] CourseCreatingDto courseCreatingDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var course = await this.courseService.Create(professorId, courseCreatingDto);

                return(CreatedAtRoute("FindCourseById", new { courseId = course.Id }, course));
            }
            catch (ProfessorNotFoundException professorNotFoundException)
            {
                return(NotFound(professorNotFoundException.Message));
            }
        }