public LinqPlaceOrderPage(IWebDriver driver, PurchaseTestInput purchaseTestInput) : base(driver) { this.purchaseTestInput = purchaseTestInput; this.creditCardSpecification = new ExpressionSpecification <PurchaseTestInput>(x => !string.IsNullOrEmpty(x.CreditCardNumber)); this.freePurchaseSpecification = new ExpressionSpecification <PurchaseTestInput>(x => x.TotalPrice == 0); this.wiretransferSpecification = new ExpressionSpecification <PurchaseTestInput>(x => x.IsWiretransfer); this.promotionalPurchaseSpecification = new ExpressionSpecification <PurchaseTestInput>(x => x.IsPromotionalPurchase && x.TotalPrice < 5); }
public OrderTestContext(PurchaseTestInput purchaseTestInput, OrderTestContextConfigurator orderTestContextConfigurator) { PurchaseTestInput = purchaseTestInput; IsPromoCodePurchase = orderTestContextConfigurator.FreePurchaseSpecification.Or(orderTestContextConfigurator.PromotionalPurchaseSpecification). IsSatisfiedBy(purchaseTestInput); IsCreditCardPurchase = orderTestContextConfigurator.CreditCardSpecification.And(orderTestContextConfigurator.WiretransferSpecification.Not()).And(orderTestContextConfigurator.FreePurchaseSpecification.Not()).And(orderTestContextConfigurator.PromotionalPurchaseSpecification.Not()). IsSatisfiedBy(purchaseTestInput); }
public void TestRules_NormalConditions() { var purchaseTestInput = new PurchaseTestInput() { IsWiretransfer = false, IsPromotionalPurchase = false, TotalPrice = 100, CreditCardNumber = "378734493671000" }; if (string.IsNullOrEmpty(purchaseTestInput.CreditCardNumber) && !purchaseTestInput.IsWiretransfer && purchaseTestInput.IsPromotionalPurchase && purchaseTestInput.TotalPrice == 0) { PerformUiAssert("Assert volume discount promotion amount. + additional UI actions"); } if (!string.IsNullOrEmpty(purchaseTestInput.CreditCardNumber) && !purchaseTestInput.IsWiretransfer && !purchaseTestInput.IsPromotionalPurchase && purchaseTestInput.TotalPrice > 20) { PerformUiAssert("Assert that total amount label is over 20$ + additional UI actions"); } else if (!string.IsNullOrEmpty(purchaseTestInput.CreditCardNumber) && !purchaseTestInput.IsWiretransfer && !purchaseTestInput.IsPromotionalPurchase && purchaseTestInput.TotalPrice > 30) { Console.WriteLine("Assert that total amount label is over 30$ + additional UI actions"); } else if (!string.IsNullOrEmpty(purchaseTestInput.CreditCardNumber) && !purchaseTestInput.IsWiretransfer && !purchaseTestInput.IsPromotionalPurchase && purchaseTestInput.TotalPrice > 40) { Console.WriteLine("Assert that total amount label is over 40$ + additional UI actions"); } else if (!string.IsNullOrEmpty(purchaseTestInput.CreditCardNumber) && !purchaseTestInput.IsWiretransfer && !purchaseTestInput.IsPromotionalPurchase && purchaseTestInput.TotalPrice > 50) { PerformUiAssert("Assert that total amount label is over 50$ + additional UI actions"); } else { Debug.WriteLine("Perform other UI actions"); } }
public PlaceOrderPage(IWebDriver driver, PurchaseTestInput purchaseTestInput) : base(driver) { _purchaseTestInput = purchaseTestInput; _promotionalPurchaseSpecification = new PromotionalPurchaseSpecification(purchaseTestInput); _wiretransferSpecification = new WiretransferSpecification(purchaseTestInput); _creditCardSpecification = new CreditCardSpecification(purchaseTestInput); _freePurchaseSpecification = new FreePurchaseSpecification(); IsPromoCodePurchase = _freePurchaseSpecification.Or(_promotionalPurchaseSpecification).IsSatisfiedBy(_purchaseTestInput); IsCreditCardPurchase = _creditCardSpecification. And(_wiretransferSpecification.Not()). And(_freePurchaseSpecification.Not()). And(_promotionalPurchaseSpecification.Not()). IsSatisfiedBy(_purchaseTestInput); }
public PlaceOrderPage(IWebDriver driver, PurchaseTestInput purchaseTestInput) : base(driver) { this.purchaseTestInput = purchaseTestInput; this.promotionalPurchaseSpecification = new PromotionalPurchaseSpecification(purchaseTestInput); this.wiretransferSpecification = new WiretransferSpecification(purchaseTestInput); this.creditCardSpecification = new CreditCardSpecification(purchaseTestInput); this.freePurchaseSpecification = new FreePurchaseSpecification(); this.IsPromoCodePurchase = this.freePurchaseSpecification.Or(this.promotionalPurchaseSpecification).IsSatisfiedBy(this.purchaseTestInput); this.IsCreditCardPurchase = this.creditCardSpecification. And(this.wiretransferSpecification.Not()). And(this.freePurchaseSpecification.Not()). And(this.promotionalPurchaseSpecification.Not()). IsSatisfiedBy(this.purchaseTestInput); }
public void TestRules() { var purchaseTestInput = new PurchaseTestInput() { IsWiretransfer = false, IsPromotionalPurchase = false, TotalPrice = 100, CreditCardNumber = "378734493671000" }; var rulesEvaluator = new RulesEvaluator(); rulesEvaluator.Eval(new PromotionalPurchaseRule(purchaseTestInput, () => PerformUiAssert())); rulesEvaluator.Eval(new CreditCardChargeRule(purchaseTestInput, 20, () => PerformUiAssert())); rulesEvaluator.OtherwiseEval(new PromotionalPurchaseRule(purchaseTestInput, () => PerformUiAssert())); rulesEvaluator.OtherwiseEval(new CreditCardChargeRule <CreditCardChargeRuleRuleResult>(purchaseTestInput, 30)); rulesEvaluator.OtherwiseEval(new CreditCardChargeRule <CreditCardChargeRuleAssertResult>(purchaseTestInput, 40)); rulesEvaluator.OtherwiseEval(new CreditCardChargeRule(purchaseTestInput, 50, () => PerformUiAssert())); rulesEvaluator.OtherwiseDo(() => Debug.WriteLine("Perform other UI actions")); rulesEvaluator.EvaluateRulesChains(); }
public CreditCardChargeRule(PurchaseTestInput purchaseTestInput, decimal totalPriceLowerBoundary, Action actionToBeExecuted) : base(actionToBeExecuted) { _purchaseTestInput = purchaseTestInput; _totalPriceLowerBoundary = totalPriceLowerBoundary; }
public PromotionalPurchaseRule(PurchaseTestInput purchaseTestInput, Action actionToBeExecuted) : base(actionToBeExecuted) { this.purchaseTestInput = purchaseTestInput; }
public CreditCardChargeRule(PurchaseTestInput purchaseTestInput, decimal totalPriceLowerBoundary) { _purchaseTestInput = purchaseTestInput; _totalPriceLowerBoundary = totalPriceLowerBoundary; }