示例#1
0
        public async Task E_Possivel_Invocar_a_Controller_Get_por_Cep()
        {
            var serviceMock = new Mock <ICepService>();
            var Cep         = Faker.RandomNumber.Next(1, 10000).ToString();
            var Logradouro  = Faker.Address.StreetName();
            var Numero      = Faker.RandomNumber.Next(1, 10000).ToString();
            var MunicipioId = Guid.NewGuid();

            serviceMock.Setup(c => c.Get(It.IsAny <string>())).ReturnsAsync(
                new CepDto
            {
                Id          = Guid.NewGuid(),
                Cep         = Cep,
                Logradouro  = Logradouro,
                Numero      = Numero,
                MunicipioId = MunicipioId
            }
                );

            _controller = new CepsController(serviceMock.Object);
            _controller.ModelState.AddModelError("Id", "Formato invalido");

            var result = await _controller.Get("999");

            Assert.True(result is BadRequestObjectResult);
        }
示例#2
0
        public async Task E_Possivel_Invocar_a_Controller_Get()
        {
            var serviceMock = new Mock <ICepService>();
            var Cep         = Faker.RandomNumber.Next(1, 10000).ToString();
            var Logradouro  = Faker.Address.StreetName();
            var Numero      = Faker.RandomNumber.Next(1, 10000).ToString();
            var MunicipioId = Guid.NewGuid();

            serviceMock.Setup(c => c.Get(It.IsAny <Guid>())).ReturnsAsync(
                new CepDto
            {
                Id          = Guid.NewGuid(),
                Cep         = Cep,
                Logradouro  = Logradouro,
                Numero      = Numero,
                MunicipioId = MunicipioId
            }
                );

            _controller = new CepsController(serviceMock.Object);

            var result = await _controller.Get(Guid.NewGuid());

            Assert.True(result is OkObjectResult);
        }
        public async Task E_Possivel_Invocar_a_Controller_Get()
        {
            var serviceMock = new Mock <ICepService>();

            serviceMock.Setup(m => m.Get(It.IsAny <Guid>())).Returns(Task.FromResult((CepDto)null));

            _controller = new CepsController(serviceMock.Object);
            var result = await _controller.Get(Guid.NewGuid());

            Assert.True(result is NotFoundResult);
        }
        public async Task RetornoNotFoundTest()
        {
            var serviceMock = new Mock <ICepService>();

            serviceMock.Setup(m => m.Get(It.IsAny <string>())).Returns(Task.FromResult((CepDto)null));

            _controller = new CepsController(serviceMock.Object);
            var result = await _controller.Get("13480000");

            Assert.True(result is NotFoundResult);
        }
        public async Task E_Possivel_Invocar_a_Controller_Get_por_Cep()
        {
            var serviceMock = new Mock <ICepService>();

            serviceMock.Setup(c => c.Get(It.IsAny <string>())).Returns(Task.FromResult((CepDto)null));

            _controller = new CepsController(serviceMock.Object);

            var result = await _controller.Get("999");

            Assert.True(result is NotFoundResult);
        }
示例#6
0
        public async Task E_Possivel_Invocar_a_Controller_Get()
        {
            var serviceMock = new Mock <ICepService>();

            serviceMock.Setup(m => m.Get(It.IsAny <Guid>())).ReturnsAsync(
                new CepDto {
                Id         = Guid.NewGuid(),
                Logradouro = "Teste de Rua",
            }
                );

            _controller = new CepsController(serviceMock.Object);
            var result = await _controller.Get(Guid.NewGuid());

            Assert.True(result is OkObjectResult);
        }
        public async Task ReturnOkTest()
        {
            var serviceMock = new Mock <ICepService>();

            serviceMock.Setup(m => m.Get(It.IsAny <string>())).ReturnsAsync(
                new CepDto
            {
                Id         = Guid.NewGuid(),
                Logradouro = "Teste de Rua",
            }
                );

            _controller = new CepsController(serviceMock.Object);

            var result = await _controller.Get("13480000");

            Assert.True(result is OkObjectResult);
        }
        public async Task E_Possivel_Invocar_a_Controller_GetByCep()
        {
            var serviceMock = new Mock <ICepService>();

            serviceMock.Setup(m => m.Get(It.IsAny <string>())).ReturnsAsync(
                new CepDto {
                Id         = Guid.NewGuid(),
                Logradouro = "Teste de Rua",
            }
                );

            _controller = new CepsController(serviceMock.Object);
            _controller.ModelState.AddModelError("Id", "Formato Inválido");

            var result = await _controller.Get("1");

            Assert.True(result is BadRequestObjectResult);
        }
示例#9
0
        public async Task BadRequestRetorno()
        {
            var serviceMock = new Mock <ICepService>();

            serviceMock.Setup(m => m.Get(It.IsAny <string>()))
            .ReturnsAsync(
                new CepDto
            {
                Id         = Guid.NewGuid(),
                Logradouro = "Teste de rua"
            }
                );
            _controller = new CepsController(serviceMock.Object);
            _controller.ModelState.AddModelError("Id", "Formato invalido");

            var result = await _controller.Get("13480000");

            Assert.True(result is BadRequestObjectResult);
        }