public async Task 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) { var canRefund = await _orderProcessingService.CanRefundAsync(order); canRefund.Should().BeTrue(); } else { var canRefund = await _orderProcessingService.CanRefundAsync(order); canRefund.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; var canRefund = await _orderProcessingService.CanRefundAsync(order); canRefund.Should().BeFalse(); } } } }