示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }