public void MiddlewaresAtDifferentStages() { using (ApplicationDeployer deployer = new ApplicationDeployer()) { string applicationUrl = deployer.Deploy(HostType.IIS, MiddlewaresAtDifferentStagesConfiguration); WebDeployer webDeployer = (WebDeployer)deployer.Application; webDeployer.Application.Deploy("IntegratedPipelineTest.aspx", File.ReadAllText("RequirementFiles\\IntegratedPipelineTest.aspx")); string responseText = HttpClientUtility.GetResponseTextFromUrl(applicationUrl + "/IntegratedPipelineTest.aspx"); Assert.True(responseText.Contains("IntegratedPipelineTest"), "IntegratedPipelineTest.aspx not returned"); Assert.True(responseText.Contains("0;1;2;3;4;5;6;7;8;9;10"), "Pipeline order incorrect"); } }
public void IntegratedPipelineWithMapMiddleware() { using (ApplicationDeployer deployer = new ApplicationDeployer()) { string applicationUrl = deployer.Deploy(HostType.IIS, WithMapMiddleware); WebDeployer webDeployer = (WebDeployer)deployer.Application; Directory.CreateDirectory(Path.Combine(webDeployer.Application.VirtualDirectories[0].PhysicalPath, "Branch1")); Directory.CreateDirectory(Path.Combine(webDeployer.Application.VirtualDirectories[0].PhysicalPath, "Branch2")); webDeployer.Application.Deploy("Branch1\\IntegratedPipelineTest.aspx", File.ReadAllText("RequirementFiles\\IntegratedPipelineTest.aspx")); webDeployer.Application.Deploy("Branch2\\IntegratedPipelineTest.aspx", File.ReadAllText("RequirementFiles\\IntegratedPipelineTest.aspx")); Assert.True(HttpClientUtility.GetResponseTextFromUrl(applicationUrl + "/Branch1/IntegratedPipelineTest.aspx").Contains("1;11"), "Pipeline order incorrect"); Assert.True(HttpClientUtility.GetResponseTextFromUrl(applicationUrl + "/Branch2/IntegratedPipelineTest.aspx").Contains("1;21"), "Pipeline order incorrect"); } }
public void EnvironmentDictionaryVerification(HostType hostType) { using (ApplicationDeployer deployer = new ApplicationDeployer()) { string applicationUrl = deployer.Deploy(hostType, Configuration); List <KeyValuePair <string, string[]> > additionalHeaders = new List <KeyValuePair <string, string[]> >(); additionalHeaders.Add(new KeyValuePair <string, string[]>("CustomHeader1", new string[] { "CustomHeaderValue1" })); string targetUrl = applicationUrl + "/Test/?query=value"; string getResponseText = HttpClientUtility.GetResponseTextFromUrl(targetUrl, additionalHeaders); Uri targetUri = new Uri(targetUrl); Dictionary <string, string> owinDictionary = ParseResponse(getResponseText); #region Utility function Func <string, bool> validatePath = (httpMethod) => { if (hostType == HostType.IIS) { WebDeployer webDeployer = (WebDeployer)deployer.Application; string virtualDirectoryName = webDeployer.Application.Path.TrimStart(new char[] { '/' }); if (owinDictionary["owin.RequestPath"] != "/Test/" || owinDictionary["owin.RequestPathBase"] != "/" + virtualDirectoryName) { Assert.True(false, string.Format("{0} environment dictionary verification failed. At least one of the values returned by the server does not match the expected value. String returned by server : {1}", httpMethod, getResponseText)); } } else { if (owinDictionary["owin.RequestPath"].TrimStart(new char[] { '/' }) != targetUri.AbsolutePath.TrimStart(new char[] { '/' }) || !string.IsNullOrWhiteSpace(owinDictionary["owin.RequestPathBase"])) { Assert.True(false, string.Format("{0} environment dictionary verification failed. At least one of the values returned by the server does not match the expected value. String returned by server : {1}", httpMethod, getResponseText)); } } return(true); }; #endregion //GET validatePath("GET"); if (owinDictionary["CustomHeader1"] != "CustomHeaderValue1" || !owinDictionary["Host"].Contains(targetUri.Host) || owinDictionary["owin.RequestMethod"] != "GET" || owinDictionary["owin.RequestProtocol"] != "HTTP/1.1" || owinDictionary["owin.RequestQueryString"] != targetUri.Query.TrimStart(new char[] { '?' }) || owinDictionary["owin.RequestScheme"] != targetUri.Scheme || owinDictionary["owin.Version"] != "1.0") { Assert.True(false, string.Format("GET environment dictionary verification failed. At least one of the values returned by the server does not match the expected value. String returned by server : {0}", getResponseText)); } //POST string postResponseText = HttpClientUtility.PostResponseTextFromUrl(targetUrl, additionalHeaders); owinDictionary = ParseResponse(postResponseText); validatePath("POST"); if (owinDictionary["CustomHeader1"] != "CustomHeaderValue1" || !owinDictionary["Host"].Contains(targetUri.Host) || owinDictionary["owin.RequestMethod"] != "POST" || owinDictionary["owin.RequestProtocol"] != "HTTP/1.1" || owinDictionary["owin.RequestQueryString"] != targetUri.Query.TrimStart(new char[] { '?' }) || owinDictionary["owin.RequestScheme"] != targetUri.Scheme || owinDictionary["owin.Version"] != "1.0") { Assert.True(false, string.Format("POST environment dictionary verification failed. At least one of the values returned by the server does not match the expected value. String returned by server : {0}", postResponseText)); } } }