public void TestBasketPurchasePolicy_MaxBasketPriceInValid() { cart.AddProduct(store, 2, 2, false); cart.AddProduct(store, 3, 2, false); PurchaseBasket basket = cart.GetBasket(store); PurchasePolicy purchaseplc = new BasketPurchasePolicy(maxBasketPrice: 100, pre: preConditionsDict[CommonStr.PurchasePreCondition.MaxBasketPrice]); bool eligiblePurchase = purchaseplc.IsEligiblePurchase(basket); Assert.AreEqual(false, eligiblePurchase); }
public void TestBasketPurchasePolicy_NoCondtion() { cart.AddProduct(store, 2, 2, false); cart.AddProduct(store, 3, 2, false); PurchaseBasket basket = cart.GetBasket(store); PurchasePolicy purchaseplc = new BasketPurchasePolicy(pre: preConditionsDict[CommonStr.PurchasePreCondition.allwaysTrue]); bool eligiblePurchase = purchaseplc.IsEligiblePurchase(basket); Assert.AreEqual(true, eligiblePurchase); }
public void TestBasketPurchasePolicy_MinItemPerBasketValid() { cart.AddProduct(store, 1, 2, false); cart.AddProduct(store, 2, 2, false); cart.AddProduct(store, 3, 2, false); PurchaseBasket basket = cart.GetBasket(store); PurchasePolicy purchaseplc = new BasketPurchasePolicy(minItems: 6, pre: preConditionsDict[CommonStr.PurchasePreCondition.MinItemsAtBasket]); bool eligiblePurchase = purchaseplc.IsEligiblePurchase(basket); Assert.AreEqual(true, eligiblePurchase); }
public void TestCompund_ILLegal() { // cant buy more than 10 prods and cant buy more than 1 of item 2 cart.AddProduct(store, 1, 7, false); cart.AddProduct(store, 2, 2, false); PurchaseBasket basket = cart.GetBasket(store); store.ActiveStore = false; PurchasePolicy purchaseplcMinItemsAtBasket = new BasketPurchasePolicy(minItems: 12, pre: preConditionsDict[CommonStr.PurchasePreCondition.MinItemsAtBasket]); PurchasePolicy purchaseplcMaxItemAtBasket = new BasketPurchasePolicy(maxItems: 10, pre: preConditionsDict[CommonStr.PurchasePreCondition.MaxItemsAtBasket]); CompundPurchasePolicy compund = new CompundPurchasePolicy(CommonStr.PurchaseMergeTypes.AND, null); compund.add(purchaseplcMinItemsAtBasket); compund.add(purchaseplcMaxItemAtBasket); bool eligiblePurchase = compund.IsEligiblePurchase(basket); Assert.AreEqual(false, eligiblePurchase); }