예제 #1
0
        public void Ensure_order_can_only_be_refunded_when_paymentstatus_is_paid_and_paymentModule_supports_refund()
        {
            _paymentService.Setup(ps => ps.SupportRefund("paymentMethodSystemName_that_supports_refund")).Returns(true);
            _paymentService.Setup(ps => ps.SupportRefund("paymentMethodSystemName_that_doesn't_support_refund")).Returns(false);
            var order = new Order
            {
                OrderTotal = 1,
                PaymentMethodSystemName = "paymentMethodSystemName_that_supports_refund"
            };

            foreach (OrderStatus os in Enum.GetValues(typeof(OrderStatus)))
            {
                foreach (PaymentStatus ps in Enum.GetValues(typeof(PaymentStatus)))
                {
                    foreach (ShippingStatus ss in Enum.GetValues(typeof(ShippingStatus)))
                    {
                        order.OrderStatus    = os;
                        order.PaymentStatus  = ps;
                        order.ShippingStatus = ss;

                        if (ps == PaymentStatus.Paid)
                        {
                            _orderProcessingService.CanRefund(order).ShouldBeTrue();
                        }
                        else
                        {
                            _orderProcessingService.CanRefund(order).ShouldBeFalse();
                        }
                    }
                }
            }



            order.PaymentMethodSystemName = "paymentMethodSystemName_that_doesn't_support_refund";
            foreach (OrderStatus os in Enum.GetValues(typeof(OrderStatus)))
            {
                foreach (PaymentStatus ps in Enum.GetValues(typeof(PaymentStatus)))
                {
                    foreach (ShippingStatus ss in Enum.GetValues(typeof(ShippingStatus)))
                    {
                        order.OrderStatus    = os;
                        order.PaymentStatus  = ps;
                        order.ShippingStatus = ss;

                        _orderProcessingService.CanRefund(order).ShouldBeFalse();
                    }
                }
            }
        }
예제 #2
0
        public void EnsureOrderCanOnlyBeRefundedWhenPaymentStatusIsPaidAndPaymentModuleSupportsRefund()
        {
            var order = new Order
            {
                OrderTotal = 1,
                PaymentMethodSystemName = "Payments.TestMethod"
            };

            TestPaymentMethod.TestSupportRefund = true;

            foreach (OrderStatus os in Enum.GetValues(typeof(OrderStatus)))
            {
                foreach (PaymentStatus ps in Enum.GetValues(typeof(PaymentStatus)))
                {
                    foreach (ShippingStatus ss in Enum.GetValues(typeof(ShippingStatus)))
                    {
                        order.OrderStatus    = os;
                        order.PaymentStatus  = ps;
                        order.ShippingStatus = ss;

                        if (ps == PaymentStatus.Paid)
                        {
                            _orderProcessingService.CanRefund(order).Should().BeTrue();
                        }
                        else
                        {
                            _orderProcessingService.CanRefund(order).Should().BeFalse();
                        }
                    }
                }
            }

            TestPaymentMethod.TestSupportRefund = false;

            foreach (OrderStatus os in Enum.GetValues(typeof(OrderStatus)))
            {
                foreach (PaymentStatus ps in Enum.GetValues(typeof(PaymentStatus)))
                {
                    foreach (ShippingStatus ss in Enum.GetValues(typeof(ShippingStatus)))
                    {
                        order.OrderStatus    = os;
                        order.PaymentStatus  = ps;
                        order.ShippingStatus = ss;

                        _orderProcessingService.CanRefund(order).Should().BeFalse();
                    }
                }
            }
        }