Esempio n. 1
0
        public async Task When_pay_whole_remaining_value_on_order_should_add_payment_to_list_change_remaining_value_to_pay_and_change_status_to_paid_out()
        {
            //Given
            var posOrder = GetBasicPOSOrder();
            var customer = new Entities.User.Customer {
                Id = 1
            };
            var valueToPay     = posOrder.OrderTotal;
            var paymentService = MockPaymentProcessor(mock =>
                                                      mock.Setup(m => m.ProcessAsync(It.IsAny <IPaymentRequest>()))
                                                      .ReturnsAsync(PaymentResult.Paid(Payment.Create(null, null, valueToPay, valueToPay))));
            var paymentMethod = new InHands(acceptsPartialPayment: false, paymentService);

            //When
            posOrder.DefinePaymentMethod(paymentMethod);
            await posOrder.PayAsync(valueToPay, customer);

            //Then
            Assert.True(posOrder.PaidOut);
            Assert.Equal(0, posOrder.RemainingValueToPay);
            Assert.Single(posOrder.Payments);
        }