public void Purchase_SeleniumTestingToolsCookbook()
        {
            string itemUrl = "/Selenium-Testing-Cookbook-Gundecha-Unmesh/dp/1849515743";
            string itemPrice = "40.49";
            ClientPurchaseInfo clientPurchaseInfo = new ClientPurchaseInfo(
            new ClientAddressInfo()
            {
                FullName = "John Smith",
                Country = "United States",
                Address1 = "950 Avenue of the Americas",
                State = "New York",
                City = "New York City",
                Zip = "10001-2121",
                Phone = "00164644885569"
            })
            {
                GiftWrapping = GiftWrappingStyles.None
            };
            ClientLoginInfo clientLoginInfo = new ClientLoginInfo()
            {
                Email = "*****@*****.**",
                Password = "******"
            };

            new PurchaseContext(new SalesTaxOrderValidationStrategy()).PurchaseItem(itemUrl, itemPrice, clientLoginInfo, clientPurchaseInfo);
        }
Exemplo n.º 2
0
 public void ValidateOrderSummary(string itemPrice, ClientPurchaseInfo clientPurchaseInfo)
 {
     foreach (var currentStrategy in orderpurchaseStrategies)
     {
         currentStrategy.ValidateOrderSummary(itemPrice, clientPurchaseInfo);
     }
 }
 public void ValidateClientPurchaseInfo(ClientPurchaseInfo clientPurchaseInfo)
 {
     if (!clientPurchaseInfo.ShippingInfo.Country.Equals("United States"))
     {
         throw new ArgumentException("If the NoTaxesOrderPurchaseStrategy is used, the country should be set to United States because otherwise no sales tax is going to be applied.");
     }
 }
 public void ValidateClientPurchaseInfo(ClientPurchaseInfo clientPurchaseInfo)
 {
     if (clientPurchaseInfo.GiftWrapping.Equals(GiftWrappingStyles.None))
     {
         throw new ArgumentException("The gift wrapping style cannot be set to None if the GiftOrderPurchaseStrategy should be executed.");
     }
 }
Exemplo n.º 5
0
 public void ValidateClientPurchaseInfo(ClientPurchaseInfo clientPurchaseInfo)
 {
     foreach (var currentStrategy in orderpurchaseStrategies)
     {
         currentStrategy.ValidateClientPurchaseInfo(clientPurchaseInfo);
     }
 }
        public void ValidateOrderSummary(string itemsPrice, ClientPurchaseInfo clientPurchaseInfo)
        {
            Countries currentCountry = (Countries)Enum.Parse(typeof(Countries), clientPurchaseInfo.BillingInfo.Country);
            decimal currentItemPrice = decimal.Parse(itemsPrice);
            decimal vatTax = this.VatTaxCalculationService.Calculate(currentItemPrice, currentCountry);

            PlaceOrderPage.Instance.Validate().EstimatedTaxPrice(vatTax.ToString());
        }
 public void ValidateClientPurchaseInfo(ClientPurchaseInfo clientPurchaseInfo)
 {
     if (clientPurchaseInfo.ShippingInfo.Country.Equals(Countries.UnitedStates))
     {
         throw new ArgumentException("If the NoTaxesOrderPurchaseStrategy is used, the country cannot be set to United States because a sales tax is going to be applied.");
     }
     // Add another validation for the EU contries because for them a VAT Tax is going to be applied if not VAT ID is set.
 }
        public decimal CalculateBeforeTaxPrice(decimal itemsPrice, ClientPurchaseInfo clientPurchaseInfo)
        {
            decimal beforeTaxPrice = default(decimal);
            decimal shippingCosts = CalculateShippingPrice(clientPurchaseInfo);
            beforeTaxPrice = itemsPrice + shippingCosts;

            return beforeTaxPrice;
        }
        public void ValidateOrderSummary(string itemsPrice, ClientPurchaseInfo clientPurchaseInfo)
        {
            States currentState = (States)Enum.Parse(typeof(States), clientPurchaseInfo.ShippingInfo.State);
            decimal currentItemPrice = decimal.Parse(itemsPrice);
            decimal salesTax = this.SalesTaxCalculationService.Calculate(currentItemPrice, currentState, clientPurchaseInfo.ShippingInfo.Zip);

            PlaceOrderPage.Instance.Validate().EstimatedTaxPrice(salesTax.ToString());
        }
        public decimal CalculateTotalPrice(decimal itemsPrice, decimal estimatedTax, ClientPurchaseInfo clientPurchaseInfo)
        {
            decimal totalPrice = default(decimal);
            decimal shippingCosts = CalculateShippingPrice(clientPurchaseInfo);
            totalPrice = itemsPrice + estimatedTax + shippingCosts;

            return totalPrice;
        }
Exemplo n.º 11
0
 private void PurchaseItemInternal(string itemUrl, ClientLoginInfo clientLoginInfo, ClientPurchaseInfo clientPurchaseInfo)
 {
     ItemPage.Instance.Navigate(itemUrl);
     ItemPage.Instance.ClickBuyNowButton();
     PreviewShoppingCartPage.Instance.ClickProceedToCheckoutButton();
     SignInPage.Instance.Login(clientLoginInfo.Email, clientLoginInfo.Password);
     ShippingAddressPage.Instance.FillShippingInfo(clientPurchaseInfo);
     ShippingAddressPage.Instance.ClickContinueButton();
     ShippingPaymentPage.Instance.ClickBottomContinueButton();
     ShippingPaymentPage.Instance.ClickTopContinueButton();
 }
Exemplo n.º 12
0
 public void PurchaseItem(string itemUrl, string itemPrice, ClientLoginInfo clientLoginInfo, ClientPurchaseInfo clientPurchaseInfo)
 {
     ItemPage.Instance.Navigate(itemUrl);
     ItemPage.Instance.ClickBuyNowButton();
     PreviewShoppingCartPage.Instance.ClickProceedToCheckoutButton();
     SignInPage.Instance.Login(clientLoginInfo.Email, clientLoginInfo.Password);
     ShippingAddressPage.Instance.FillShippingInfo(clientPurchaseInfo);
     ShippingAddressPage.Instance.ClickContinueButton();
     ShippingPaymentPage.Instance.ClickBottomContinueButton();
     ShippingPaymentPage.Instance.ClickTopContinueButton();
     this.orderValidationStrategy.ValidateOrderSummary(itemPrice, clientPurchaseInfo);
 }
        public void Purchase_SeleniumTestingToolsCookbook()
        {
            string itemUrl = "/Selenium-Testing-Cookbook-Gundecha-Unmesh/dp/1849515743";
            string itemPrice = "40.49";
            var shippingInfo = new ClientAddressInfo()
            {
                FullName = "John Smith",
                Country = "United States",
                Address1 = "950 Avenue of the Americas",
                State = "New York",
                City = "New York City",
                Zip = "10001-2121",
                Phone = "00164644885569"
            };
            var billingInfo = new ClientAddressInfo()
            {
                FullName = "Anton Angelov",
                Country = "Bulgaria",
                Address1 = "950 Avenue of the Americas",
                City = "Sofia",
                Zip = "1672",
                Phone = "0894464647"
            };
            ClientPurchaseInfo clientPurchaseInfo = new ClientPurchaseInfo(billingInfo, shippingInfo)
            {
                GiftWrapping = Enums.GiftWrappingStyles.Fancy
            };
            ClientLoginInfo clientLoginInfo = new ClientLoginInfo()
            {
                Email = "*****@*****.**",
                Password = "******"
            };

            new PurchaseContext(new SalesTaxOrderPurchaseStrategy(), new VatTaxOrderPurchaseStrategy(), new GiftOrderPurchaseStrategy())
            .PurchaseItem(itemUrl, itemPrice, clientLoginInfo, clientPurchaseInfo);
        }
 public decimal CalculateShippingPrice(ClientPurchaseInfo clientPurchaseInfo)
 {
     decimal shippingCosts = this.ShippingCostsCalculationService.Calculate(clientPurchaseInfo.ShippingInfo.Country, clientPurchaseInfo.ShippingInfo.State, clientPurchaseInfo.ShippingInfo.Address1, clientPurchaseInfo.ShippingInfo.Zip);
     return shippingCosts;
 }
 public void ValidateOrderSummary(string itemsPrice, ClientPurchaseInfo clientPurchaseInfo)
 {
     PlaceOrderPage.Instance.Validate().EstimatedTaxPrice("0.00");
 }
        public void ValidateOrderSummary(string itemsPrice, ClientPurchaseInfo clientPurchaseInfo)
        {
            decimal giftWrapPrice = this.GiftWrappingPriceCalculationService.Calculate(clientPurchaseInfo.GiftWrapping);

            PlaceOrderPage.Instance.Validate().GiftWrapPrice(giftWrapPrice.ToString());
        }
Exemplo n.º 17
0
 public void PurchaseItemShippingTax(string itemUrl, string itemPrice, string shippingTax, ClientLoginInfo clientLoginInfo, ClientPurchaseInfo clientPurchaseInfo)
 {
     PurchaseItemInternal(itemUrl, clientLoginInfo, clientPurchaseInfo);
     PlaceOrderPage.Instance.Validate().ShippingTaxPrice(shippingTax);
 }
Exemplo n.º 18
0
 public void PurchaseItemGiftWrapping(string itemUrl, string itemPrice, string giftWrapTax, ClientLoginInfo clientLoginInfo, ClientPurchaseInfo clientPurchaseInfo)
 {
     PurchaseItemInternal(itemUrl, clientLoginInfo, clientPurchaseInfo);
     PlaceOrderPage.Instance.Validate().GiftWrapPrice(giftWrapTax);
 }
Exemplo n.º 19
0
 public void PurchaseItemSalesTax(string itemUrl, string itemPrice, string taxAmount, ClientLoginInfo clientLoginInfo, ClientPurchaseInfo clientPurchaseInfo)
 {
     PurchaseItemInternal(itemUrl, clientLoginInfo, clientPurchaseInfo);
     PlaceOrderPage.Instance.Validate().EstimatedTaxPrice(taxAmount);
 }
 public void ValidateClientPurchaseInfo(ClientPurchaseInfo clientPurchaseInfo)
 {
    // Throw a new Argument exection if the country is not part of the EU Union.
 }