예제 #1
0
        public async Task should_handle_existing_po_payment()
        {
            // Arrange
            var mockedPOTotal = 20;
            var existing      = PaymentMocks.PaymentList(PaymentMocks.POPayment(40));

            _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().PatchAsync <HSPayment>(OrderDirection.Incoming, mockOrderID, mockPoPaymentID, Arg.Is <PartialPayment>(p => p.Amount == mockedPOTotal));
        }
예제 #2
0
        public async Task should_handle_new_po_payment()
        {
            // Arrange
            var mockedPOTotal = 50;
            var existing      = PaymentMocks.EmptyPaymentsList();

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

            _orderCalc.GetPurchaseOrderTotal(Arg.Any <HSOrderWorksheet>())
            .Returns(mockedPOTotal);

            // 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
        public async Task should_delete_stale_payments()
        {
            // Arrange
            var mockedCreditCardTotal = 20;
            var existing = PaymentMocks.PaymentList(PaymentMocks.POPayment(20));

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

            _orderCalc.GetCreditCardTotal(Arg.Any <HSOrderWorksheet>())
            .Returns(mockedCreditCardTotal);

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

            // Assert
            await _oc.Payments.Received().DeleteAsync(OrderDirection.Incoming, mockOrderID, mockPoPaymentID);

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