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(); }
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(); }
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)); }
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); }
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)); } }