public async Task Get_ShouldReturnPhoneBook() { var PhoneBook = FakeObjects.FakeObjects.GetListPhoneBook(); _phoneBookService.GetData().Returns(PhoneBook); var actionResult = await _sut.Get(); actionResult.Value.Equals(PhoneBook); }
public async Task Get_ReturnsOkResult() { var result = await _controller.Get(); var okResult = result as OkObjectResult; // assert Assert.NotNull(okResult); Assert.True(okResult is OkObjectResult); Assert.Equal(StatusCodes.Status200OK, okResult.StatusCode); }
public async Task Get_ReturnsHttpNotFound_WhenNoData() { // Arrange _mockRepo.Setup(repo => repo.Get()) .ReturnsAsync((IEnumerable <PhoneBook>)null); var controller = new PhoneBookController(_mockRepo.Object); // Act var result = await controller.Get(); // Assert Assert.IsType <NotFoundResult>(result.Result); }
public async Task Get_ReturnsBadRequest_WhenNoIdSupplied() { // Arrange Guid id = Guid.Empty; PhoneBook mockPhoneBook = new PhoneBook(); var controller = new PhoneBookController(_mockRepo.Object); // Act var result = await controller.Get(id); // Assert Assert.IsType <BadRequestResult>(result.Result); }
public async Task Get_ReturnsHttpOk_WhenDataIsPresent() { // Arrange _mockRepo.Setup(repo => repo.Get()) .ReturnsAsync((IEnumerable <PhoneBook>)_phoneBooks); var controller = new PhoneBookController(_mockRepo.Object); // Act var result = await controller.Get(); // Assert Assert.IsType <OkObjectResult>(result.Result); }
public async Task Get_ReturnsHttpOk_WhenIdSupplied() { // Arrange Guid id = Guid.NewGuid(); PhoneBook mockPhoneBook = new PhoneBook(); _mockRepo.Setup(repo => repo.Get(id)) .ReturnsAsync(mockPhoneBook); var controller = new PhoneBookController(_mockRepo.Object); // Act var result = await controller.Get(id); // Assert Assert.IsType <OkObjectResult>(result.Result); }
public void GetAllTest() { //arrange //act //get resulst by making requerst var result = _controller.Get(); //assert Assert.IsType <OkObjectResult>(result.Result); var list = result.Result as OkObjectResult; Assert.IsType <List <PhoneBookForReturnDTO> >(list.Value); var listPhoneBooks = list.Value as List <PhoneBookForReturnDTO>; Assert.Equal(2, listPhoneBooks.Count); }