Tests.ExceptionTestCases.TestIisExpressUnknownSection C# (CSharp) Method

TestIisExpressUnknownSection() private method

private TestIisExpressUnknownSection ( ) : void
return void
        public void TestIisExpressUnknownSection()
        {
            var directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            Environment.SetEnvironmentVariable("JEXUS_TEST_HOME", directoryName);

            if (directoryName == null)
            {
                return;
            }

            string Current = Path.Combine(directoryName, @"applicationHost.config");
            string Original = Path.Combine(directoryName, @"original2.config");
            TestHelper.CopySiteConfig(directoryName, "original_unknown_section.config");
            File.Copy(Original, Current, true);
            TestHelper.FixPhysicalPathMono(Current);

#if IIS
            var server = new ServerManager(Current);
#else
            var server = new IisExpressServerManager(Current);
#endif
            var config = server.Sites[0].Applications[0].GetWebConfiguration();
            var exception = Assert.Throws<COMException>(
                () =>
                    {
                        // enable Windows authentication
                        var windowsSection =
                            config.GetSection("system.webServer/security/authentication/windowsAuthentication");
                    });
            var siteConfig = Path.Combine(directoryName, "WebSite1", "web.config");
#if IIS
            Assert.Equal(string.Format("Filename: \\\\?\\{0}\r\nError: \r\n", siteConfig), exception.Message);
#else
            Assert.Equal(string.Format("Filename: \\\\?\\{0}\r\nLine number: 10\r\nError: Unrecognized element 'test'\r\n\r\n", siteConfig), exception.Message);
#endif
        }