예제 #1
0
        public void should_throw_if_no_payments()
        {
            // Arrange
            _oc.Payments.ListAsync <HSPayment>(OrderDirection.Incoming, orderID, filters: Arg.Is <object>(f => (string)f == "Type=CreditCard"))
            .Returns(Task.FromResult(PaymentMocks.EmptyPaymentsList()));
            var payment = ValidIntegrationsPayment();

            // Act
            var ex = Assert.ThrowsAsync <OrderCloudIntegrationException>(async() => await _sut.AuthorizePayment(payment, userToken, merchantID));

            // Assert
            Assert.AreEqual("Payment.MissingCreditCardPayment", ex.ApiError.ErrorCode);
        }
예제 #2
0
        public async Task should_handle_new_po_payment()
        {
            // Arrange
            var mockedPOTotal = 20;
            var existing      = PaymentMocks.EmptyPaymentsList();

            _oc.Payments.ListAsync <HSPayment>(OrderDirection.Incoming, mockOrderID)
            .Returns(Task.FromResult(existing));
            var requested = PaymentMocks.Payments(PaymentMocks.POPayment());

            // Act
            var result = await _sut.SavePayments(mockOrderID, requested, mockUserToken);

            // Assert
            await _oc.Payments.Received().CreateAsync <HSPayment>(OrderDirection.Incoming, mockOrderID, Arg.Is <HSPayment>(p => p.ID == mockPoPaymentID && p.Amount == mockedPOTotal));
        }
예제 #3
0
        [Test] public async Task should_handle_new_cc_payment()
        {
            // Arrange
            var mockedCreditCardTotal = 20;
            var existing = PaymentMocks.EmptyPaymentsList();

            _oc.Payments.ListAsync <HSPayment>(OrderDirection.Incoming, mockOrderID)
            .Returns(Task.FromResult(existing));
            var requested = PaymentMocks.Payments(PaymentMocks.CCPayment(creditcard1));

            // Act
            var result = await _sut.SavePayments(mockOrderID, requested, mockUserToken);

            // Assert
            await _oc.Payments.DidNotReceive().DeleteAsync(OrderDirection.Incoming, mockOrderID, Arg.Any <string>());

            await _oc.Payments.Received().CreateAsync <HSPayment>(OrderDirection.Outgoing, mockOrderID, Arg.Is <HSPayment>(p => p.ID == mockCCPaymentID && p.Type == PaymentType.CreditCard && p.Amount == mockedCreditCardTotal && p.Accepted == false), mockUserToken);
        }