This file contains hidden or 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
[XmlRoot(ElementName = "sites")] | |
public class Sites | |
{ | |
[XmlElement(ElementName = "site")] | |
public List<Site> Site { get; set; } | |
} | |
[XmlRoot(ElementName = "site")] | |
public class Site | |
{ |
This file contains hidden or 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 class RedirectService : IDisposable | |
{ | |
readonly IRedirectStrategy redirectEngine; | |
private Sites sites; | |
public RedirectService(IRedirectStrategy redirectEngine) | |
{ | |
this.redirectEngine = redirectEngine; | |
this.redirectEngine.Initialize(); | |
this.InitializeRedirectUrls(); |
This file contains hidden or 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 interface IRedirectStrategy : IDisposable | |
{ | |
void Initialize(); | |
string NavigateToFromUrl(string fromUrl); | |
void Dispose(); | |
} |
This file contains hidden or 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 class WebDriverRedirectStrategy : IRedirectStrategy | |
{ | |
private IWebDriver driver; | |
public void Initialize() | |
{ | |
this.driver = new FirefoxDriver(); | |
} | |
public void Dispose() |
This file contains hidden or 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 class WebRequestRedirectStrategy : IRedirectStrategy | |
{ | |
public void Initialize() | |
{ | |
} | |
public string NavigateToFromUrl(string fromUrl) | |
{ | |
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(fromUrl); | |
request.Method = "HEAD"; |
This file contains hidden or 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
[TestClass] | |
public class RedirectsTester | |
{ | |
[TestMethod] | |
public void TestRedirects() | |
{ | |
var redirectService = new RedirectService(new WebRequestRedirectStrategy()); | |
using (redirectService) | |
{ | |
redirectService.TestRedirects(); |
This file contains hidden or 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 interface IOrderPurchaseStrategy | |
{ | |
void ValidateOrderSummary(string itemPrice, ClientPurchaseInfo clientPurchaseInfo); | |
void ValidateClientPurchaseInfo(ClientPurchaseInfo clientPurchaseInfo); | |
} |
This file contains hidden or 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 class SalesTaxOrderPurchaseStrategy : IOrderPurchaseStrategy | |
{ | |
public SalesTaxOrderPurchaseStrategy() | |
{ | |
this.SalesTaxCalculationService = new SalesTaxCalculationService(); | |
} | |
public SalesTaxCalculationService SalesTaxCalculationService { get; set; } | |
public void ValidateOrderSummary(string itemsPrice, ClientPurchaseInfo clientPurchaseInfo) |
This file contains hidden or 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 class PurchaseContext | |
{ | |
private readonly IOrderValidationStrategy orderValidationStrategy; | |
public PurchaseContext(IOrderValidationStrategy orderValidationStrategy) | |
{ | |
this.orderValidationStrategy = orderValidationStrategy; | |
} | |
public void PurchaseItem(string itemUrl, string itemPrice, ClientLoginInfo clientLoginInfo, ClientPurchaseInfo clientPurchaseInfo) |
This file contains hidden or 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 class PurchaseContext | |
{ | |
private readonly IOrderPurchaseStrategy[] orderpurchaseStrategies; | |
public PurchaseContext(params IOrderPurchaseStrategy[] orderpurchaseStrategies) | |
{ | |
this.orderpurchaseStrategies = orderpurchaseStrategies; | |
} | |
public void PurchaseItem(string itemUrl, string itemPrice, ClientLoginInfo clientLoginInfo, ClientPurchaseInfo clientPurchaseInfo) |