Last active
December 11, 2017 10:34
-
-
Save angelovstanton/c1c795b7c4f40925e028 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class PlaceOrderPage : BasePage | |
{ | |
private readonly PurchaseTestInput purchaseTestInput; | |
private readonly PromotionalPurchaseSpecification promotionalPurchaseSpecification; | |
private readonly CreditCardSpecification creditCardSpecification; | |
private readonly WiretransferSpecification wiretransferSpecification; | |
private readonly FreePurchaseSpecification freePurchaseSpecification; | |
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 bool IsPromoCodePurchase { get; private set; } | |
public bool IsCreditCardPurchase { get; private set; } | |
public override string Url | |
{ | |
get | |
{ | |
return @"pathToYourSite"; | |
} | |
} | |
public void ChoosePaymentMethod() | |
{ | |
if (this.IsCreditCardPurchase) | |
{ | |
this.CreditCard.SendKeys("371449635398431"); | |
this.SecurityNumber.SendKeys("1234"); | |
} | |
else | |
{ | |
this.Wiretransfer.SendKeys("pathToFile"); | |
} | |
} | |
public void TypePromotionalCode(string promoCode) | |
{ | |
if (this.IsPromoCodePurchase) | |
{ | |
this.PromotionalCode.SendKeys(promoCode); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment