// We must enter the discount price, however, limit number can be null public void VerifyDiscountCodeInList(bool hasCode, string codeName, ChangePriceDirection changePriceDirection, ChangeType changeType, double discountPrice, int? limitNumber) { string codeLinkLocator = ComposeCodeLinkLocator(codeName); if (hasCode != UIUtil.DefaultProvider.IsElementPresent(codeLinkLocator, LocateBy.XPath)) { Assert.Fail(string.Format("DiscountCode '{0}' was{1} found in the code list!", codeName, hasCode ? " NOT" : string.Empty)); } VerifyCodeTypeAndName(DiscountCodeType.DiscountCode, codeName); VerifyCodeChangeAmount(codeName, changePriceDirection, changeType, discountPrice); VerifyCodeLimitNumber(codeName, limitNumber); }
public double CalculateDiscountPrice(double standardPrice, ChangePriceDirection changePriceDirection, ChangeType changeType, double discountAmount) { switch (changePriceDirection) { case ChangePriceDirection.Increase: break; case ChangePriceDirection.Decrease: discountAmount = -discountAmount; break; default: break; } double discountPrice = standardPrice; switch (changeType) { case ChangeType.FixedAmount: discountPrice += discountAmount; break; case ChangeType.Percent: discountPrice = discountPrice * (100 + discountAmount) / 100; break; default: break; } return discountPrice; }
public void VerifyCodeChangeAmount(string codeName, ChangePriceDirection changePriceDirection, ChangeType changeType, double discountPrice) { string codeLinkLocator = ComposeCodeLinkLocator(codeName); //Verify code ChangePriceDirection(decrease or increase) and DiscountPrice and ChangeType(Percentage or FixedAmount) string codeChangeAmountLocator = string.Format("{0}/../../td[3]", codeLinkLocator); StringBuilder expectedAmount = new StringBuilder(); if (changePriceDirection == ChangePriceDirection.Decrease) { expectedAmount.Append("-"); } expectedAmount.Append(Convert.ToString(discountPrice)); if (changeType == ChangeType.Percent) { expectedAmount.Append("%"); } VerifyTool.VerifyValue(expectedAmount.ToString(), UIUtil.DefaultProvider.GetText(codeChangeAmountLocator, LocateBy.XPath), "The change amount is : {0}"); }
public void VerifyDiscountCodeInBulkLoadCodes(bool hasCode, string codeName, ChangePriceDirection changePriceDirection, ChangeType changeType, double discountPrice, int? limitNumber) { UIUtil.DefaultProvider.WaitForElementPresent(BulkCodesTxtareaLocator, LocateBy.Id); bool actual = UIUtil.DefaultProvider.GetText(BulkCodesTxtareaLocator, LocateBy.Id).Contains( GetBulkLoadCodeStringForDiscountCode(codeName, changePriceDirection, changeType, discountPrice, limitNumber)); if (hasCode != actual) { Assert.Fail(string.Format("DiscountCode '{0}' was{1} found in bulk codes!", codeName, hasCode ? " NOT" : string.Empty)); } }
public void SetDiscountCodeValues(string code, ChangePriceDirection changePriceDirection, ChangeType changeType, double discountPrice, int? limitNumber) { this.SetCodeType(DiscountCodeType.DiscountCode); // Set Change Price By Direction: Decrease or Increase this.SetChangeDirection(changePriceDirection); // Set Change Type : percent or fixed amount this.SetChangeType(changeType); // Set Change Price this.SetDiscountChangePrice(discountPrice); // Set Code Name this.SetCodeName(code); // Set Limit Number this.SetCodeLimitNumber(limitNumber); }
public void SetDiscountCodeAndAddAnother(string code, ChangePriceDirection changePriceDirection, ChangeType changeType, double discountPrice, int? limitNumber) { this.SetDiscountCodeValues(code, changePriceDirection, changeType, discountPrice, limitNumber); this.SaveAndNewDiscountCode(); }
public void SetCodeAndAddAnother(DiscountCodeType discountCodeType, string code, ChangePriceDirection changePriceDirection, ChangeType changeType, double discountPrice, int? limitNumber) { if (discountCodeType == DiscountCodeType.DiscountCode) { this.SetDiscountCodeAndAddAnother(code, changePriceDirection, changeType, discountPrice, limitNumber); } else { this.SetAccessCodeAndAddAnother(code, limitNumber); } }
public void SetChangeDirection(ChangePriceDirection changePriceDirection) { UIUtil.DefaultProvider.SelectWithText("ctl00_cphDialog_ddlChangePriceByDirection", changePriceDirection.ToString(), LocateBy.Id); }
public string GetBulkLoadCodeStringForDiscountCode(string code, ChangePriceDirection changePriceDirection, ChangeType changeType, double discountPrice, int? limitNumber) { StringBuilder codeString = new StringBuilder(); codeString.Append(code); codeString.Append("="); if (changePriceDirection == ChangePriceDirection.Decrease) { codeString.Append("-"); } codeString.Append(Convert.ToString(discountPrice)); if (changeType == ChangeType.Percent) { codeString.Append("%"); } if (limitNumber.HasValue) { codeString.Append("(" + limitNumber.Value.ToString() + ")"); } return codeString.ToString(); }