public async Task It_Is_Possible_To_Invoke_The_Controller_GetCompleteByIBGECode() { var serviceMock = new Mock <ICityService>(); serviceMock.Setup(s => s.GetCompleteByIBGECode(It.IsAny <int>())).Returns(Task.FromResult((CityDtoComplete)null)); _controller = new CitiesController(serviceMock.Object); var result = await _controller.GetCompleteByIBGECode(1); Assert.True(result is NotFoundResult); }
public async Task It_Is_Possible_To_Invoke_The_Controller_GetCompleteByIBGECode() { var serviceMock = new Mock <ICityService>(); serviceMock.Setup(s => s.GetCompleteByIBGECode(It.IsAny <int>())).ReturnsAsync( new CityDtoComplete { Id = Guid.NewGuid(), Name = "Passo Fundo" }); _controller = new CitiesController(serviceMock.Object); _controller.ModelState.AddModelError("Id", "Formato inválido."); var result = await _controller.GetCompleteByIBGECode(1); Assert.True(result is BadRequestObjectResult); }
public async Task It_Is_Possible_To_Invoke_The_Controller_GetCompleteByIBGECode() { var serviceMock = new Mock <ICityService>(); serviceMock.Setup(s => s.GetCompleteByIBGECode(It.IsAny <int>())).ReturnsAsync( new CityDtoComplete { Id = Guid.NewGuid(), Name = "Passo Fundo" }); _controller = new CitiesController(serviceMock.Object); var result = await _controller.GetCompleteByIBGECode(1); Assert.True(result is OkObjectResult); var resultValue = ((OkObjectResult)result).Value as CityDtoComplete; Assert.NotNull(resultValue); Assert.Equal("Passo Fundo", resultValue.Name); }