Example #1
0
        async Task Listar()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Clientes.Clear();

                var consultaCliente = ClienteAppService.GetListAsync(new GetClienteInput());
                var clientes        = consultaCliente.Result.Items.ToList();
                foreach (var cliente in clientes)
                {
                    Clientes.Add(cliente);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        public async Task ObterTodosPorCidade_CidadeVazioOuNulo_ThrowsException()
        {
            var clienteRepository = new Mock <IRepository <Cliente> >();
            var clienteAppService = new ClienteAppService(clienteRepository.Object, mapper);

            var ex = await Assert.ThrowsAsync <Exception>(() => clienteAppService.ObterTodosPorCidade(""));

            var ex2 = await Assert.ThrowsAsync <Exception>(() => clienteAppService.ObterTodosPorCidade(null));

            Assert.Equal("Cidade não pode estar vazio ou nulo.", ex.Message);
            Assert.Equal("Cidade não pode estar vazio ou nulo.", ex2.Message);
        }
        public async Task ObterTodosPorIdade_IdadeMenorIgualZero_ThrowsException()
        {
            var clienteRepository = new Mock <IRepository <Cliente> >();
            var clienteAppService = new ClienteAppService(clienteRepository.Object, mapper);

            var ex = await Assert.ThrowsAsync <Exception>(() => clienteAppService.ObterTodosPorIdade(0));

            var ex2 = await Assert.ThrowsAsync <Exception>(() => clienteAppService.ObterTodosPorIdade(-1));

            Assert.Equal("Idade deve ser maior que 0.", ex.Message);
            Assert.Equal("Idade deve ser maior que 0.", ex2.Message);
        }
        public async Task ObterTodosPorEstado_EstadoInvalido_RetornaListaVazia()
        {
            var clienteRepository = new Mock <IRepository <Cliente> >();

            clienteRepository.Setup(c => c.ReadAll())
            .Returns(Task.FromResult((IEnumerable <Cliente>) new List <Cliente>
            {
                new Cliente("Levi Juan Henrique da Rosa", 18, "837.218.376-73", "33.171.161-8", new DateTime(2001, 02, 27), "Araxá", "MG", "Peixes", "Giovanna Bianca Cristiane", "Hugo Antonio Roberto da Rosa", "*****@*****.**", "jqAYDrlOk5", "38183-044", 715, "(34) 3670-2306", "(34) 99963-1139", "1,73", 78, "A-", "Vermelho"),
                new Cliente("Renan Caio Victor Caldeira", 51, "569.980.286-01", "32.273.285-2", new DateTime(1965, 08, 13), "Ituiutaba", "MG", "Leão", "Tereza Antônia", "Ruan Yuri Caldeira", "*****@*****.**", "XAbUybYUDp", "38304-120", 684, "(34) 2528-6956", "(34) 99812-7018", "1,98", 91, "O+", "Vermelho"),
                new Cliente("Sebastiana Maitê Ribeiro", 51, "206.334.456-65", "20.840.528-8", new DateTime(1968, 12, 26), "Passos", "MG", "Capricórnio", "Joana Rebeca Isabelle", "Cláudio Henry Ribeiro", "*****@*****.**", "WDljFP7aqa", "37902-340", 728, "(35) 2615-6221", "(35) 99290-5767", "1,65", 71, "B-", "Verde")
            }));

            var clienteAppService = new ClienteAppService(clienteRepository.Object, mapper);

            var clientes = await clienteAppService.ObterTodosPorEstado("QW");

            Assert.Empty(clientes);
        }
Example #5
0
 public ClientesController(ClienteAppService clienteAppService)
 {
     _clienteAppService = clienteAppService;
 }
 public ClienteController()
 {
     _clienteApp = new ClienteAppService();
 }
Example #7
0
 public ClienteAppServiceTests()
 {
     clienteValidation = new ClienteValidation();
     clienteService    = new Mock <IClienteService>();
     clienteAppService = new ClienteAppService(clienteService.Object);
 }
Example #8
0
 public CelulaController(ClienteAppService clienteappservice, IAgenciaAppService agenciaappservice)
 {
     _clienteappservice = clienteappservice;
     _agenciaappservice = agenciaappservice;
 }
Example #9
0
 public ClienteTest()
 {
     _repository = new Mock <ClienteRepository>(null);
     _appService = new ClienteAppService(_repository.Object);
 }
Example #10
0
 public ClientesController(CotizacionAppDbContext context, ClienteAppService clienteAppService)
 {
     _context           = context;
     _clienteAppService = clienteAppService;
 }
 /// <summary>
 /// Construtor
 /// </summary>
 public ClientesController(LabSysManagerContext dbContext, IMapper mapper)
 {
     ClienteRepository = new ClienteRepository(dbContext);
     ClienteAppService = new ClienteAppService(ClienteRepository, mapper);
 }