public void Execute_11_NoMaximumApplications(
                CartAnyItemQuantityXSellPriceAction action,
                IRuleValue <int> quantityX,
                IRuleValue <decimal> sellPrice,
                //IRuleValue<int> maximumApplications,
                Cart cart,
                CartTotals cartTotals,
                CommerceContext commerceContext,
                IRuleExecutionContext context)
            {
                /**********************************************
                * Arrange
                **********************************************/
                cart.Adjustments.Clear();
                cart.Lines.ForEach(l => l.Adjustments.Clear());

                context.Fact <CommerceContext>().ReturnsForAnyArgs(commerceContext);
                commerceContext.AddObject(cartTotals);
                commerceContext.AddObject(cart);
                action.QuantityX           = quantityX;
                action.SellPrice           = sellPrice;
                action.MaximumApplications = null;

                /**********************************************
                * Act
                **********************************************/
                Action executeAction = () => action.Execute(context);

                /**********************************************
                * Assert
                **********************************************/
                executeAction.Should().Throw <Exception>();
                cart.Lines.SelectMany(l => l.Adjustments).Should().BeEmpty();
                cart.Adjustments.Should().BeEmpty();
            }
            public void Execute_TimesQualified_Two_MaximumApplications_One(
                CartAnyItemQuantityXSellPriceAction action,
                IRuleValue <int> quantityX,
                IRuleValue <decimal> sellPrice,
                IRuleValue <int> maximumApplications,
                Cart cart,
                CommerceContext commerceContext,
                IRuleExecutionContext context)
            {
                /**********************************************
                * Arrange
                **********************************************/
                cart.Adjustments.Clear();
                cart.Lines.ForEach(l => l.Adjustments.Clear());

                var globalPricingPolicy = commerceContext.GetPolicy <GlobalPricingPolicy>();

                globalPricingPolicy.ShouldRoundPriceCalc         = false;
                cart.Lines.ForEach(l => l.Totals.SubTotal.Amount = 100);
                while (cart.Lines.Count > 1)
                {
                    cart.Lines.RemoveAt(0);
                }
                var cartline = cart.Lines[0];

                cartline.Quantity = 4;
                cartline.Totals.SubTotal.Amount = 300;
                cartline.SetPolicy(new PurchaseOptionMoneyPolicy
                {
                    SellPrice = new Money(75)
                });
                var cartTotals = new CartTotals(cart);

                quantityX.Yield(context).ReturnsForAnyArgs(2);
                sellPrice.Yield(context).ReturnsForAnyArgs(40);
                maximumApplications.Yield(context).ReturnsForAnyArgs(1);

                context.Fact <CommerceContext>().ReturnsForAnyArgs(commerceContext);
                commerceContext.AddObject(cartTotals);
                commerceContext.AddObject(cart);
                action.QuantityX           = quantityX;
                action.SellPrice           = sellPrice;
                action.MaximumApplications = maximumApplications;

                /**********************************************
                * Act
                **********************************************/
                Action executeAction = () => action.Execute(context);

                /**********************************************
                * Assert
                **********************************************/
                executeAction.Should().NotThrow <Exception>();
                cart.Lines.SelectMany(l => l.Adjustments).Should().HaveCount(1);
                cart.Adjustments.Should().BeEmpty();
                cartTotals.Lines[cartline.Id].SubTotal.Amount.Should().Be(190);
            }