예제 #1
0
        public void ExplicitlyRegisterOwinHttpHandler()
        {
            using (ApplicationDeployer deployer = new ApplicationDeployer())
            {
                deployer.AutomaticAppStartupInWebHost = false;
                string url           = deployer.Deploy(HostType.IIS);
                var    webConfigPath = deployer.GetWebConfigPath();

                var addHandler = "<system.webServer>" +
                                 "<handlers>" +
                                 "<add name=\"Owin\" verb=\"*\" type=\"Microsoft.Owin.Host.SystemWeb.OwinHttpHandler, Microsoft.Owin.Host.SystemWeb\" path=\"*\" />" +
                                 "</handlers>" +
                                 "</system.webServer>";

                var configuration = new XmlDocument()
                {
                    InnerXml = File.ReadAllText(webConfigPath)
                };
                var configurationNode = configuration.SelectSingleNode("/configuration");
                configurationNode.InnerXml += addHandler;
                File.WriteAllText(webConfigPath, configuration.InnerXml);

                ((WebDeployer)deployer.Application).Application.Deploy("Default.aspx", File.ReadAllText("RequirementFiles\\Default.aspx"));

                Assert.Equal(Startup.RESULT, HttpClientUtility.GetResponseTextFromUrl(url + "/Default.aspx"));
                Assert.Equal(Startup.RESULT, HttpClientUtility.GetResponseTextFromUrl(url));
            }
        }
예제 #2
0
        public void Static_DirectoryBrowserDefaults(HostType hostType)
        {
            using (ApplicationDeployer deployer = new ApplicationDeployer())
            {
                string applicationUrl = deployer.Deploy(hostType, DirectoryBrowserDefaultsConfiguration);

                HttpResponseMessage response = null;

                //1. Check directory browsing enabled at application level
                var responseText = HttpClientUtility.GetResponseTextFromUrl(applicationUrl, out response);
                Assert.True(!string.IsNullOrWhiteSpace(responseText), "Received empty response");
                Assert.True((response.Content).Headers.ContentType.ToString() == "text/html; charset=utf-8");
                Assert.Contains("RequirementFiles/", responseText);

                //2. Check directory browsing @RequirementFiles with a ending '/'
                responseText = HttpClientUtility.GetResponseTextFromUrl(applicationUrl + "RequirementFiles/", out response);
                Assert.True(!string.IsNullOrWhiteSpace(responseText), "Received empty response");
                Assert.True((response.Content).Headers.ContentType.ToString() == "text/html; charset=utf-8");
                Assert.True(responseText.Contains("Dir1/") && responseText.Contains("Dir2/") && responseText.Contains("Dir3/"), "Directories Dir1, Dir2, Dir3 not found");

                //2. Check directory browsing @RequirementFiles with request path not ending '/'
                responseText = HttpClientUtility.GetResponseTextFromUrl(applicationUrl + "RequirementFiles", out response);
                Assert.True(!string.IsNullOrWhiteSpace(responseText), "Received empty response");
                Assert.True((response.Content).Headers.ContentType.ToString() == "text/html; charset=utf-8");
                Assert.True(responseText.Contains("Dir1/") && responseText.Contains("Dir2/") && responseText.Contains("Dir3/"), "Directories Dir1, Dir2, Dir3 not found");
            }
        }
        public void ApplicationPoolStop(HostType hostType)
        {
            var serverInstance = new NotificationServer();

            serverInstance.StartNotificationService();
            try
            {
                using (ApplicationDeployer deployer = new ApplicationDeployer())
                {
                    string applicationUrl = deployer.Deploy(hostType, Configuration);
                    Assert.True(HttpClientUtility.GetResponseTextFromUrl(applicationUrl) == "SUCCESS");

                    if (hostType == HostType.IIS)
                    {
                        string webConfig        = deployer.GetWebConfigPath();
                        string webConfigContent = File.ReadAllText(webConfig);
                        File.WriteAllText(webConfig, webConfigContent);
                    }
                }

                bool receivedNotification = serverInstance.NotificationReceived.WaitOne(20 * 1000);
                Assert.True(receivedNotification, "Cancellation token was not issued on closing host");
            }
            finally
            {
                serverInstance.Dispose();
            }
        }
예제 #4
0
        public void InstanceContext(HostType hostType)
        {
            using (ApplicationDeployer deployer = new ApplicationDeployer())
            {
                string   applicationUrl = deployer.Deploy <InstanceContextStartup>(hostType);
                string[] urls           = new string[] { applicationUrl, applicationUrl + "/one", applicationUrl + "/two" };

                bool failed = false;

                foreach (string url in urls)
                {
                    string previousResponse = null;
                    for (int count = 0; count < 3; count++)
                    {
                        string currentResponse = HttpClientUtility.GetResponseTextFromUrl(url);

                        if (!currentResponse.Contains("SUCCESS") || (previousResponse != null && currentResponse != previousResponse))
                        {
                            failed = true;
                        }

                        previousResponse = currentResponse;
                    }
                }

                Assert.True(!failed, "At least one of the instance contexts is not correct");
            }
        }
예제 #5
0
 public void ConvertibleMiddlewareTest(HostType hostType)
 {
     using (ApplicationDeployer deployer = new ApplicationDeployer())
     {
         string applicationUrl = deployer.Deploy <ConvertibleMiddleWarePatternStartup>(hostType);
         Assert.Equal("SUCCESS", HttpClientUtility.GetResponseTextFromUrl(applicationUrl));
     }
 }
예제 #6
0
 public void AllowedConfigurationSignature1(HostType hostType)
 {
     using (ApplicationDeployer deployer = new ApplicationDeployer())
     {
         string applicationUrl = deployer.Deploy <AllowedNonDefaultConfigurationSignatures1>(hostType);
         Assert.Equal("SUCCESS", HttpClientUtility.GetResponseTextFromUrl(applicationUrl));
     }
 }
예제 #7
0
 public void OwinAbstractMiddleware(HostType hostType)
 {
     using (ApplicationDeployer deployer = new ApplicationDeployer())
     {
         string applicationUrl = deployer.Deploy(hostType, OwinAbstractMiddlewareConfiguration);
         Assert.Equal("SUCCESS", HttpClientUtility.GetResponseTextFromUrl(applicationUrl));
     }
 }
예제 #8
0
 public void DefaultDiscoveryTest(HostType hostType)
 {
     using (ApplicationDeployer deployer = new ApplicationDeployer())
     {
         string applicationUrl = deployer.Deploy(hostType);
         string responseText   = HttpClientUtility.GetResponseTextFromUrl(applicationUrl);
         Assert.Equal(Startup.RESULT, responseText);
     }
 }
예제 #9
0
        public void WelcomePage(HostType hostType)
        {
            using (ApplicationDeployer deployer = new ApplicationDeployer())
            {
                string applicationUrl = deployer.Deploy(hostType, WelcomePageConfiguration);

                HttpResponseMessage response;
                Assert.True(HttpClientUtility.GetResponseTextFromUrl(applicationUrl, out response).ToLower().Contains("your owin application has been successfully started"));
                Assert.Equal("text/html", response.Content.Headers.ContentType.MediaType.ToLower());
            }
        }
예제 #10
0
 public void InvalidAppStartupInConfiguration(HostType hostType)
 {
     using (ApplicationDeployer deployer = new ApplicationDeployer())
     {
         string applicationUrl   = deployer.Deploy(hostType, ValidConfiguration);
         string webConfig        = deployer.GetWebConfigPath();
         string webConfigContent = File.ReadAllText(webConfig).Replace(typeof(NegativeScenarios).Name, "NotExistingStartupClass");
         File.WriteAllText(webConfig, webConfigContent);
         Assert.True(HttpClientUtility.GetResponseTextFromUrl(applicationUrl).Contains(expectedExceptionType.Name), "Fatal error not thrown with invalid owin:AppStartup");
     }
 }
예제 #11
0
 public void OnSendingHeaders(HostType hostType)
 {
     using (ApplicationDeployer deployer = new ApplicationDeployer())
     {
         string applicationUrl = deployer.Deploy <OnSendingHeadersTest>(hostType);
         HttpResponseMessage httpResponseMessage = null;
         HttpClientUtility.GetResponseTextFromUrl(applicationUrl, out httpResponseMessage);
         string receivedHeaderValue = httpResponseMessage.Headers.GetValues("DummyHeader").First();
         Assert.True(receivedHeaderValue == "DummyHeaderValue,DummyHeaderValue",
                     string.Format("Expected header values : {0}. Received header values : {1}", "DummyHeaderValue,DummyHeaderValue", receivedHeaderValue));
     }
 }
예제 #12
0
        public void DefaultStageMarkersTest()
        {
            using (ApplicationDeployer deployer = new ApplicationDeployer())
            {
                string applicationUrl = deployer.Deploy(HostType.IIS, DefaultStageMarkersTestConfiguration);
                ((WebDeployer)deployer.Application).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"), "Pipeline order incorrect");
            }
        }
예제 #13
0
        public void MapOwinPath()
        {
            using (ApplicationDeployer deployer = new ApplicationDeployer())
            {
                string url = deployer.Deploy(HostType.IIS, MapOwinPathConfiguration);
                ((WebDeployer)deployer.Application).Application.Deploy("Default.aspx", File.ReadAllText("RequirementFiles\\Default.aspx"));

                Assert.True(HttpClientUtility.GetResponseTextFromUrl(url + "/Default.aspx").Contains("Asp.net Test page"), "Default.aspx page not returned successfully in SxS mode");
                Assert.Equal("prefix1", HttpClientUtility.GetResponseTextFromUrl(url + "/prefix1"));
                Assert.Equal("prefix1Append", HttpClientUtility.GetResponseTextFromUrl(url + "/prefix1Append"));
                Assert.Equal("prefix2", HttpClientUtility.GetResponseTextFromUrl(url + "/prefix2"));
            }
        }
예제 #14
0
        public void OrderOfExecution()
        {
            using (ApplicationDeployer deployer = new ApplicationDeployer())
            {
                string      applicationUrl = deployer.Deploy(HostType.IIS, OrderOfExecutionConfiguration);
                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"), "Pipeline order incorrect");
            }
        }
예제 #15
0
        public void Static_BlockedFiles(HostType hostType)
        {
            using (ApplicationDeployer deployer = new ApplicationDeployer())
            {
                var applicationUrl = deployer.Deploy(hostType, BlockedFiles_Configuration);

                var response = HttpClientUtility.GetResponseTextFromUrl(applicationUrl + "TextFile.txt");
                Assert.Equal <string>(@"BlockedFiles\TextFile", response);

                //Clock$ should not be served. This is the only file among the list of blocked files, I can create on the disk.
                response = HttpClientUtility.GetResponseTextFromUrl(applicationUrl + "clock$.txt");
                Assert.Equal <string>("FallThrough", response);
            }
        }
예제 #16
0
        public void TestResponseStatusCode(HostType hostType)
        {
            using (ApplicationDeployer deployer = new ApplicationDeployer())
            {
                string applicationUrl = deployer.Deploy(hostType, ConfigurationTest);
                HttpResponseMessage httpResponseMessage = null;

                HttpClientUtility.GetResponseTextFromUrl(applicationUrl + "/BadRequestPath", out httpResponseMessage);
                Assert.Equal(httpResponseMessage.StatusCode, HttpStatusCode.BadRequest);

                HttpClientUtility.GetResponseTextFromUrl(applicationUrl + "/GoodRequestPath", out httpResponseMessage);
                Assert.Equal(httpResponseMessage.StatusCode, HttpStatusCode.OK);
            }
        }
예제 #17
0
        public void CreateLogger(HostType hostType)
        {
            using (ApplicationDeployer deployer = new ApplicationDeployer())
            {
                var service = new NotificationServer();
                service.StartNotificationService();

                string applicationUrl = deployer.Deploy(hostType, CreateLoggerConfiguration);

                Assert.Equal("SUCCESS", HttpClientUtility.GetResponseTextFromUrl(applicationUrl));
                Assert.True(service.NotificationReceived.WaitOne(1 * 2000), "Did not receive all expected traces within expected time");
                service.Dispose();
            }
        }
예제 #18
0
        public void Static_EmbeddedDirectoryBrowserFileSystem(HostType hostType)
        {
            using (ApplicationDeployer deployer = new ApplicationDeployer())
            {
                var applicationUrl = deployer.Deploy(hostType, EmbeddedDirectoryBrowserFileSystemConfiguration);

                HttpResponseMessage response = null;

                var responseText = HttpClientUtility.GetResponseTextFromUrl(applicationUrl, out response);
                Assert.True(!string.IsNullOrWhiteSpace(responseText), "Received empty response");
                Assert.True((response.Content).Headers.ContentType.ToString() == "text/html; charset=utf-8");
                Assert.True(responseText.Contains("RequirementFiles.EmbeddedResources.SampleAVI.avi"));
            }
        }
예제 #19
0
        public void Static_EmbeddedFileSystemDefaultFiles(HostType hostType)
        {
            using (ApplicationDeployer deployer = new ApplicationDeployer())
            {
                var applicationUrl = deployer.Deploy(hostType, EmbeddedFileSystemDefaultFilesConfiguration);

                HttpResponseMessage response = null;

                var responseText = HttpClientUtility.GetResponseTextFromUrl(applicationUrl, out response);
                Assert.True(!string.IsNullOrWhiteSpace(responseText), "Received empty response");
                Assert.True((response.Content).Headers.ContentType.ToString() == "text/html");
                Assert.True(responseText.Contains("SampleHTM"));
            }
        }
예제 #20
0
        public void InvalidAssemblyNameInConfiguration(HostType hostType)
        {
            using (ApplicationDeployer deployer = new ApplicationDeployer())
            {
                string applicationUrl = deployer.Deploy(hostType, ValidConfiguration);

                string webConfig = deployer.GetWebConfigPath();
                string fullyQualifiedConfigurationMethodName = ((Action <IAppBuilder>)ValidConfiguration).GetFullyQualifiedConfigurationMethodName();
                string webConfigContent = File.ReadAllText(webConfig).
                                          Replace(fullyQualifiedConfigurationMethodName, fullyQualifiedConfigurationMethodName + ", NotExistingAssembly");
                File.WriteAllText(webConfig, webConfigContent);

                Assert.True(HttpClientUtility.GetResponseTextFromUrl(applicationUrl).Contains(expectedExceptionType.Name), "Fatal error not thrown with invalid assembly name");
            }
        }
예제 #21
0
        public void MappingMiddleware(HostType hostType)
        {
            using (ApplicationDeployer deployer = new ApplicationDeployer())
            {
                string applicationUrl = deployer.Deploy(hostType, MappingMiddlewareConfiguration);

                //Anonymous Auth routes test
                Assert.Equal(HttpClientUtility.GetResponseTextFromUrl(applicationUrl + "anonymous1"), "Anonymous1");
                Assert.Equal(HttpClientUtility.GetResponseTextFromUrl(applicationUrl + "anonymous2"), "Anonymous2");
                Assert.Equal(HttpClientUtility.GetResponseTextFromUrl(applicationUrl + "a"), "/a");
                Assert.Equal(HttpClientUtility.GetResponseTextFromUrl(applicationUrl + "a/b"), "/a/b");

                //Default application
                Assert.Equal(HttpClientUtility.GetResponseTextFromUrl(applicationUrl), "Default");
            }
        }
예제 #22
0
 public void ConfigurationMethodNotFound(HostType hostType)
 {
     using (ApplicationDeployer deployer = new ApplicationDeployer())
     {
         var expectedExceptionType = typeof(EntryPointNotFoundException);
         if (hostType != HostType.IIS)
         {
             Assert.Throws(expectedExceptionType, () => deployer.Deploy <ConfigurationMethodNotFoundTest>(hostType));
         }
         else
         {
             string applicationUrl = deployer.Deploy <ConfigurationMethodNotFoundTest>(hostType);
             Assert.True(HttpClientUtility.GetResponseTextFromUrl(applicationUrl).Contains(expectedExceptionType.Name), "Fatal error not thrown without Configuration method");
         }
     }
 }
예제 #23
0
        public void Static_DirectoryMiddlewareMappedToDifferentDirectory(HostType hostType)
        {
            using (ApplicationDeployer deployer = new ApplicationDeployer())
            {
                string applicationUrl = deployer.Deploy(hostType, DirectoryMiddlewareMappedToDifferentDirectoryConfiguration);

                HttpResponseMessage response = null;

                //1. Check directory browsing enabled at application level
                var responseText = HttpClientUtility.GetResponseTextFromUrl(applicationUrl, out response);
                Assert.True(!string.IsNullOrWhiteSpace(responseText), "Received empty response");
                Assert.True((response.Content).Headers.ContentType.ToString() == "text/html; charset=utf-8");
                Assert.Contains("Default.html", responseText);
                Assert.Contains("EmptyFile.txt", responseText);
            }
        }
예제 #24
0
        public void Static_CustomFileSystem(HostType hostType)
        {
            using (ApplicationDeployer deployer = new ApplicationDeployer())
            {
                string applicationUrl = deployer.Deploy(hostType, CustomFileSystemConfiguration);

                HttpResponseMessage response;
                var responseText = HttpClientUtility.GetResponseTextFromUrl(applicationUrl, out response);

                Assert.Equal("text/html", response.Content.Headers.ContentType.MediaType);
                for (int index = 0; index < 10; index++)
                {
                    var fileSystemEntryName = (index % 2 != 0) ? string.Format("TextFile{0}.txt", index) : string.Format("Dir{0}/", index);
                    Assert.Contains(fileSystemEntryName, responseText);
                }
            }
        }
예제 #25
0
        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");
            }
        }
예제 #26
0
        public void ErrorPage(HostType hostType)
        {
            using (ApplicationDeployer deployer = new ApplicationDeployer())
            {
                string applicationUrl = deployer.Deploy(hostType, ErrorPageConfiguration);

                HttpResponseMessage response;
                var responseText = HttpClientUtility.GetResponseTextFromUrl(applicationUrl, out response).ToLower();

                Assert.Contains("argumentexception", responseText);
                Assert.Contains("environment", responseText);
                Assert.Contains("stack", responseText);
                Assert.Contains("query", responseText);
                Assert.Contains("cookies", responseText);
                Assert.Equal("text/html", response.Content.Headers.ContentType.MediaType.ToLower());
            }
        }
예제 #27
0
        public void Static_DirectoryCustomRequestPathToPhysicalPathMapping(HostType hostType)
        {
            using (ApplicationDeployer deployer = new ApplicationDeployer())
            {
                string applicationUrl = deployer.Deploy(hostType, DirectoryCustomRequestPathToPhysicalPathMappingConfiguration);

                HttpResponseMessage response = null;

                //Directory with a default file - case request path ending with a '/'. A local directory referred by relative path
                var responseText = HttpClientUtility.GetResponseTextFromUrl(applicationUrl + "customrequestPath/", out response);
                Assert.Equal <HttpStatusCode>(HttpStatusCode.OK, response.StatusCode);
                Assert.True(!string.IsNullOrWhiteSpace(responseText), "Received empty response");
                Assert.True((response.Content).Headers.ContentType.ToString() == "text/html; charset=utf-8");
                Assert.Contains("Unknown.Unknown", responseText);
                Assert.Contains("Default.html", responseText);

                //Directory with a default file - case request path ending with a '/' + Head request. A local directory referred by relative path
                responseText = HttpClientUtility.HeadResponseTextFromUrl(applicationUrl + "customrequestPath/", out response);
                Assert.Equal <HttpStatusCode>(HttpStatusCode.OK, response.StatusCode);
                Assert.Equal(string.Empty, responseText);

                //Directory with a default file - case request path ending with a '/'. A local directory referred by absolute path
                responseText = HttpClientUtility.GetResponseTextFromUrl(applicationUrl + "customrequestFullPath/", out response);
                Assert.Equal <HttpStatusCode>(HttpStatusCode.OK, response.StatusCode);
                Assert.Contains("TextFile2.txt", responseText);
                Assert.Contains("Unknown.Unknown", responseText);

                //Directory with a default file - case request path ending with a '/' + Head request. A local directory referred by absolute path
                responseText = HttpClientUtility.HeadResponseTextFromUrl(applicationUrl + "customrequestFullPath/", out response);
                Assert.Equal <HttpStatusCode>(HttpStatusCode.OK, response.StatusCode);
                Assert.Equal(string.Empty, responseText);

                //Directory with a default file - case request path ending with a '/'. Mapped to a UNC path.
                responseText = HttpClientUtility.GetResponseTextFromUrl(applicationUrl + "customrequestUNCPath/", out response);
                Assert.Equal <HttpStatusCode>(HttpStatusCode.OK, response.StatusCode);
                Assert.Contains("Dir31", responseText);
                Assert.Contains("Dir32", responseText);
                Assert.Contains("TextFile3.txt", responseText);
                Assert.Contains("TextFile4.txt", responseText);

                //Directory with a default file - case request path ending with a '/' + Head request. Mapped to a UNC path.
                responseText = HttpClientUtility.HeadResponseTextFromUrl(applicationUrl + "customrequestUNCPath/", out response);
                Assert.Equal <HttpStatusCode>(HttpStatusCode.OK, response.StatusCode);
                Assert.Equal(string.Empty, responseText);
            }
        }
예제 #28
0
        public void FriendlyStartupNames(string friendlyAppStartupName, string expectedResponse)
        {
            using (ApplicationDeployer deployer = new ApplicationDeployer())
            {
                var applicationUrl = deployer.Deploy(HostType.IIS, Configuration);
                var vDirPath       = Path.GetDirectoryName(deployer.GetWebConfigPath());
                var options        = new MyStartOptions(true)
                {
                    TargetApplicationDirectory = vDirPath, FriendlyAppStartupName = friendlyAppStartupName
                };

                using (new HostServer(options))
                {
                    string response = HttpClientUtility.GetResponseTextFromUrl("http://localhost:5000/");
                    Assert.Equal(expectedResponse, response);
                }
            }
        }
예제 #29
0
        public void Static_CustomDefaultFile(HostType hostType)
        {
            using (ApplicationDeployer deployer = new ApplicationDeployer())
            {
                string applicationUrl = deployer.Deploy(hostType, CustomDefaultFileConfiguration);

                HttpResponseMessage response = null;

                //Directory with a default file - case request path ending with a '/'
                var responseText = HttpClientUtility.GetResponseTextFromUrl(applicationUrl, out response);
                Assert.Equal <HttpStatusCode>(HttpStatusCode.OK, response.StatusCode);
                Assert.Equal <bool>(true, responseText.Contains(@"Dir1\Textfile1.txt"));

                //Directory with a default file - case request path ending with a '/' + Head request
                responseText = HttpClientUtility.HeadResponseTextFromUrl(applicationUrl, out response);
                Assert.Equal <HttpStatusCode>(HttpStatusCode.OK, response.StatusCode);
                Assert.Equal <string>(string.Empty, responseText);
            }
        }
예제 #30
0
        public void Static_DirectoryBrowserCustomFormatter(HostType hostType)
        {
            using (ApplicationDeployer deployer = new ApplicationDeployer())
            {
                string applicationUrl = deployer.Deploy(hostType, DirectoryBrowserCustomFormatterConfiguration);
                HttpResponseMessage response;
                var responseText = HttpClientUtility.GetResponseTextFromUrl(applicationUrl, out response);

                Assert.Equal <string>("custom/format", response.Content.Headers.ContentType.MediaType);

                var lines = responseText.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
                Assert.NotEqual <int>(0, lines.Length);
                lines.All(line =>
                {
                    Trace.WriteLine(line);
                    var fileProperties = line.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries);
                    Assert.True(fileProperties.Count() == 5, "Insufficient file details. There should be five parts");
                    return(true);
                });
            }
        }