public void Cleanup()
 {
     this._professor            = null;
     this._professorDetailsDto  = null;
     this._professorCreatingDto = null;
     this._professorMapper      = null;
 }
 public void Setup()
 {
     this._professor            = ProfessorTestUtils.GetProfessor();
     this._professorDetailsDto  = ProfessorTestUtils.GetProfessorDetailsDto(_professor.Id);
     this._professorCreatingDto = ProfessorTestUtils.GetProfessorCreatingDto();
     this._professorMapper      = new ProfessorMapper();
 }
Exemplo n.º 3
0
 public void Setup()
 {
     client               = new CustomWebApplicationFactory <Startup>().CreateClient();
     professor1           = ProfessorTestUtils.GetProfessor();
     professor2           = ProfessorTestUtils.GetProfessor2();
     professorDetailsDto1 = ProfessorTestUtils.GetProfessorDetailsDto(professor1.Id);
     professorDetailsDto2 = ProfessorTestUtils.GetProfessorDetailsDto(professor2.Id);
     professorCreationDto = ProfessorTestUtils.GetProfessorCreatingDto();
 }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([FromBody] ProfessorCreatingDto professorCreatingDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var professor = await this.professorService.Create(professorCreatingDto);

            return(CreatedAtRoute("FindProfessorById", new { professorId = professor.Id }, professor));
        }
Exemplo n.º 5
0
 public void TestInitialize()
 {
     this._professor1           = ProfessorTestUtils.GetProfessor();
     this._professor2           = ProfessorTestUtils.GetProfessor();
     this._professorDetailsDto1 = ProfessorTestUtils.GetProfessorDetailsDto(_professor1.Id);
     this._professorDetailsDto2 = ProfessorTestUtils.GetProfessorDetailsDto(_professor2.Id);
     this._professorCreatingDto = ProfessorTestUtils.GetProfessorCreatingDto();
     this._mockReadRepository   = new Mock <IReadRepository>();
     this._mockWriteRepository  = new Mock <IWriteRepository>();
     this._mockProfessorMapper  = new Mock <IProfessorMapper>();
     _professorService          = new ProfessorService(_mockReadRepository.Object, _mockWriteRepository.Object,
                                                       _mockProfessorMapper.Object);
 }
Exemplo n.º 6
0
        public async Task <IActionResult> Update(Guid professorId, [FromBody] ProfessorCreatingDto professorCreatingDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var existingProfessor = await this.professorService.Update(professorId, professorCreatingDto);

                return(NoContent());
            }
            catch (ProfessorNotFoundException professorNotFoundException)
            {
                return(NotFound(professorNotFoundException.Message));
            }
        }