public async Task CreateNewCustomerPaymentAsync_Result_Has_Ids_Populated()
        {
            // Arrange
            var customerPayment = new NewCustomerPayment <CreditCard>
            {
                Customer = new Customer(),
                Account  = new CreditCard(),
                Payment  = new Payment()
            };

            accountService.Setup(m => m.CreateAccountAsync <CreditCard>(It.IsAny <CreditCard>())).ReturnsAsync(new CreditCard {
                Id = 1
            });
            webServiceRequest.Setup(m => m.PostDeserializedAsync <Payment, Result <Payment> >(It.IsAny <Uri>(), It.IsAny <Payment>())).ReturnsAsync(new Result <Payment> {
                Response = new Payment {
                    Id = 1
                }
            });


            // Act
            var result = await service.CreateNewCustomerPaymentAsync(customerPayment);

            // Assert
            Assert.Equal(1, result.Customer.Id);
            Assert.Equal(1, result.Account.Id);
            Assert.Equal(1, result.Payment.Id);
        }
        public async Task CreateNewCustomerPaymentAsync_Verify_CustomerService_CreateCustomerAsync()
        {
            // Arrange
            var customerPayment = new NewCustomerPayment <Ach>
            {
                Customer = new Customer(),
                Account  = new Ach(),
                Payment  = new Payment()
            };

            accountService.Setup(m => m.CreateAccountAsync <Ach>(It.IsAny <Ach>())).ReturnsAsync(new Ach {
                Id = 1
            });
            webServiceRequest.Setup(m => m.PostDeserializedAsync <Payment, Result <Payment> >(It.IsAny <Uri>(), It.IsAny <Payment>())).ReturnsAsync(new Result <Payment> {
                Response = new Payment {
                    Id = 1
                }
            });

            // Act
            await service.CreateNewCustomerPaymentAsync(customerPayment);

            // Assert
            customerService.Verify(m => m.CreateCustomerAsync(It.IsAny <Customer>()));
        }
Beispiel #3
0
        public async Task <NewCustomerPayment <T> > CreateNewCustomerPaymentAsync <T>(NewCustomerPayment <T> customerPayment)
            where T : Account, new()
        {
            try
            {
                var result = await paymentService.CreateNewCustomerPaymentAsync <T>(customerPayment);

                if (result != null)
                {
                    DumpObject("CreateNewCustomerPaymentAsync", result);
                }

                return(result);
            }
            catch (PaySimpleException ex)
            {
                DumpObject("PaySimpleException", ex.ValidationErrors);
            }
            catch (PaySimpleEndpointException ex)
            {
                DumpObject("PaySimpleEndpointException", ex.EndpointErrors);
            }

            return(null);
        }