Beispiel #1
0
        //[Test]
        public void CanGetHostingEnvironment()
        {
            var environment = HttpSimulatorTester.CallGetEnvironment();

            Assert.IsNotNull(environment);
            environment = HttpSimulatorTester.CallGetEnvironment();
            Assert.IsNotNull(environment);
        }
Beispiel #2
0
        //[RowTest]
        ////[Row("/", "/", @"c:\inetpub\wwwroot\")]
        ////[Row("/Test/Test.aspx", "/", @"c:\inetpub\wwwroot\Test\Test.aspx")]
        ////[Row("/Test/Blah/Test.aspx", "/", @"c:\inetpub\wwwroot\Test\Blah\Test.aspx")]
        ////[Row("/Test", "/Test", @"c:\inetpub\wwwroot")]
        ////[Row("/Test/", "/Test", @"c:\inetpub\wwwroot\")]
        public void CanMapPath(string virtualPath, string appPath, string expectedMapPath)
        {
            var url       = new Uri("http://localhost/Test/Test.aspx");
            var simulator = new HttpSimulator(appPath, @"c:\inetpub\wwwroot\");

            simulator.SimulateRequest(url);

            //Create a virtual path object.
            var vpath = ReflectionHelper.Instantiate("System.Web.VirtualPath, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", new[] { typeof(string) }, virtualPath);

            Assert.IsNotNull(vpath);

            var environment = HttpSimulatorTester.CallGetEnvironment();

            var vpathString = ReflectionHelper.InvokeProperty <string>(vpath, "VirtualPathString");
            var appVirtPath = ReflectionHelper.GetPrivateInstanceFieldValue <object>("_appVirtualPath", environment);

            Assert.IsNotNull(appVirtPath);
            Console.WriteLine("VPATH: " + vpath);
            Console.WriteLine("App-VPATH: " + appVirtPath);

            Console.WriteLine("vpath.VirtualPathString == '{0}'", vpathString);

            var mapping = ReflectionHelper.InvokeNonPublicMethod <string>(typeof(HostingEnvironment), "GetVirtualPathToFileMapping", vpath);

            Console.WriteLine("GetVirtualPathToFileMapping: --->{0}<---", (mapping ?? "{NULL}"));

            var o = ReflectionHelper.GetPrivateInstanceFieldValue <object>("_configMapPath", environment);

            Console.WriteLine("_configMapPath: {0}", o ?? "{null}");


            var mappedPath = ReflectionHelper.InvokeNonPublicMethod <string>(environment, "MapPathActual", vpath, false);

            Console.WriteLine("MAPPED: " + mappedPath);
            Assert.AreEqual(expectedMapPath, HttpContext.Current.Request.MapPath(virtualPath));
        }
Beispiel #3
0
 //[Test]
 public void CanStripTrailing()
 {
     Assert.AreEqual(@"c:\blah\blah2", HttpSimulatorTester.CallStripTrailingBackSlashes(@"c:\blah\blah2\"));
 }
Beispiel #4
0
 //[RowTest]
 ////[Row("/", "/")]
 ////[Row("", "/")]
 ////[Row("/test", "/test")]
 ////[Row("test/", "/test")]
 ////[Row("/test/", "/test")]
 ////[Row("/test/////", "/test")]
 ////[Row("////test/", "/test")]
 ////[Row("/test/test////", "/test/test")]
 ////[Row("/////test/test////", "/test/test")]
 ////[Row("/////test///test////", "/test/test")]
 public void CanNormalizeSlashes(string s, string expected)
 {
     Assert.AreEqual(expected, HttpSimulatorTester.CallNormalizeSlashes(s));
 }