コード例 #1
0
 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);
 }
コード例 #2
0
 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);
 }
コード例 #3
0
        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");
            }
        }
コード例 #4
0
 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);
 }
コード例 #5
0
ファイル: PlaceOrderPage.cs プロジェクト: qodetest/Projects
 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);
 }
コード例 #6
0
        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();
        }
コード例 #7
0
 public CreditCardChargeRule(PurchaseTestInput purchaseTestInput, decimal totalPriceLowerBoundary, Action actionToBeExecuted) : base(actionToBeExecuted)
 {
     _purchaseTestInput       = purchaseTestInput;
     _totalPriceLowerBoundary = totalPriceLowerBoundary;
 }
コード例 #8
0
 public PromotionalPurchaseRule(PurchaseTestInput purchaseTestInput, Action actionToBeExecuted) : base(actionToBeExecuted)
 {
     this.purchaseTestInput = purchaseTestInput;
 }
 public CreditCardChargeRule(PurchaseTestInput purchaseTestInput, decimal totalPriceLowerBoundary)
 {
     _purchaseTestInput       = purchaseTestInput;
     _totalPriceLowerBoundary = totalPriceLowerBoundary;
 }