public void CanGetHostingEnvironment()
        {
            HostingEnvironment environment = HttpSimulatorTester.CallGetEnvironment();

            Assert.IsNotNull(environment);
            environment = HttpSimulatorTester.CallGetEnvironment();
            Assert.IsNotNull(environment);
        }
        public void CanMapPath(string virtualPath, string appPath, string expectedMapPath)
        {
            Uri           url       = new Uri("http://localhost/Test/Test.aspx");
            HttpSimulator simulator = new HttpSimulator(appPath, @"c:\inetpub\wwwroot\");

            simulator.SimulateRequest(url);

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

            Assert.IsNotNull(vpath);

            HostingEnvironment environment = HttpSimulatorTester.CallGetEnvironment();

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

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

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

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

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

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

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

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

            Console.WriteLine("MAPPED: " + mappedPath);
            Assert.AreEqual(expectedMapPath, HttpContext.Current.Request.MapPath(virtualPath));
        }