Exemple #1
0
        public async Task CriarPedidoAsync()
        {
            var pedido = new PedidoFacade(_pedidoService, _clienteRepository, _pedidoRepository, _droneRepository, _pagamentoServiceFactory, _pedidoDroneRepository);

            _clienteRepository.GetByIdAsync(Arg.Any <int>()).Returns(SetupTests.GetCliente());
            _pagamentoServiceFactory.GetPagamentoServico(ETipoPagamento.CARTAO).Returns(_pagamentoServico);
            _pagamentoServico.RequisitaPagamento(Arg.Any <Pagamento>()).Returns(SetupTests.GetPagamento());

            var result = await pedido.CreatePedidoAsync(SetupTests.GetPedido());

            Assert.NotNull(result);
        }
        public async Task TestDroneAtendePedidoQuandoDroneExiste()
        {
            var droneService = new DroneService(_coordinateService,
                                                _pedidoDroneRepository,
                                                _droneRepository,
                                                _pedidoRepository);
            var pedidoService = new PedidoService(droneService, _coordinateService);

            _coordinateService.GetKmDistance(Arg.Any <Point>(), Arg.Any <Point>())
            .Returns(10);
            _pedidoDroneRepository.RetornaPedidosEmAbertoAsync().Returns(SetupTests.GetPedidoDrones(StatusEnvio.AGUARDANDO));
            _droneRepository.RetornaDroneStatus(Arg.Any <int>())
            .Returns(SetupTests.GetDroneStatusDto());
            var drone = await pedidoService.DroneAtendePedido(SetupTests.GetPedido());

            Assert.True(drone != null);
        }
Exemple #3
0
        public async Task ProcessaPagamentoTeste()
        {
            var pagamentoFacade = new PagamentoFacade(_pedidoRepository);

            var listaPagamentos = new List <PagamentoStatusDto>();

            listaPagamentos.Add(new PagamentoStatusDto()
            {
                Descricao   = "Pagamento Teste",
                IdPagamento = 1,
                Status      = EStatusPagamento.APROVADO
            });

            _pedidoRepository.PegaPedidoPendenteAsync(Arg.Any <string>()).Returns(SetupTests.GetPedido());

            await pagamentoFacade.ProcessaPagamentosAsync(listaPagamentos);

            await _pedidoRepository.Received().SaveAsync();
        }