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 GetProfessorDetailsDtoById_ShouldReturnInstanceOfProfessorDetailsDto() { // Arrange _mockReadRepository.Setup(repo => repo.GetByIdAsync <Professor>(_professor1.Id)).ReturnsAsync(_professor1); _mockProfessorMapper.Setup(mapper => mapper.Map(_professor1)).Returns(_professorDetailsDto1); // Act ProfessorDetailsDto actualProfessor = await _professorService.GetProfessorDetialsDtoById(_professor1.Id); // Assert actualProfessor.Should().BeEquivalentTo(_professorDetailsDto1); }
public async Task Create_ShouldReturnInstanceOfProfessorDetailsDto() { // Arrange _mockProfessorMapper.Setup(mapper => mapper.Map(_professor1)).Returns(_professorDetailsDto1); _mockProfessorMapper.Setup(mapper => mapper.Map(_professorCreatingDto)).Returns(_professor1); _mockWriteRepository.Setup(repo => repo.AddNewAsync <Professor>(_professor1)).Returns(() => Task.FromResult(_professor1)); // Act ProfessorDetailsDto actualProfessor = await _professorService.Create(_professorCreatingDto); // Assert actualProfessor.Should().BeEquivalentTo(_professorDetailsDto1); }
public async Task GetProfessorById_ShouldReturnProfessorDetailsDtoWithGivenId() { //Act var response = await client.GetAsync("api/professors/" + professor1.Id); //Assert response.EnsureSuccessStatusCode(); var responseString = await response.Content.ReadAsStringAsync(); ProfessorDetailsDto professorDetailsDtoReturned = JsonConvert.DeserializeObject <ProfessorDetailsDto>(responseString); professorDetailsDtoReturned.Should().BeEquivalentTo(professorDetailsDto1); }
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 PostProfessor_ShouldReturnProfessorCreatedFromGivenBody() { //Arrange var contents = new StringContent(JsonConvert.SerializeObject(professorCreationDto), Encoding.UTF8, "application/json"); //Act var response = await client.PostAsync("api/professors", contents); //Assert response.EnsureSuccessStatusCode(); var responseString = await response.Content.ReadAsStringAsync(); ProfessorDetailsDto professorDetailsDtoReturned = JsonConvert.DeserializeObject <ProfessorDetailsDto>(responseString); professorDetailsDtoReturned.Should().BeEquivalentTo(professorCreationDto, options => options.ExcludingMissingMembers()); }