Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public async Task RequisitaPagamentoTest()
        {
            var pagamento         = SetupTests.GetPagamento();
            var client            = Substitute.For <IHttpHandler>();
            var pgtoCartaoServico = new PagamentoCartaoServico(SetupTests.GetPaymentSettings(), client);


            var request     = JsonSerializer.Serialize(pagamento.ToPagamentoCreate());
            var httpContent = new StringContent(request, Encoding.UTF8, "application/json");
            var response    = new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK, Content = httpContent
            };

            client.PostAsync(Arg.Any <string>(), Arg.Any <HttpContent>()).Returns(response);

            var result = await pgtoCartaoServico.RequisitaPagamento(pagamento);

            Assert.NotNull(pagamento);
        }