public void GetPhysicalPath_Honours_WebHostPhysicalPath()
        {
            string          root = "c:/MyWebRoot";
            HttpRequestMock mock = new HttpRequestMock();

            // Note: due to the static nature of EndpointHostConfig.Instance, running this
            // test twice withing NUnit fails the test. You'll need to reload betwen each
            // run.
            Assert.AreNotEqual(EndpointHostConfig.Instance.WebHostPhysicalPath, root);

            string originalPath = EndpointHostConfig.Instance.WebHostPhysicalPath;
            string path         = mock.GetPhysicalPath();

            Assert.AreEqual(string.Format("{0}/{1}", originalPath, mock.PathInfo), path);

            EndpointHostConfig.Instance.WebHostPhysicalPath = root;
            path = mock.GetPhysicalPath();
            Assert.AreEqual(string.Format("{0}/{1}", root, mock.PathInfo), path);
        }
Esempio n. 2
0
        public void GetPhysicalPath_Honours_WebHostPhysicalPath()
        {
            using (var appHost = new BasicAppHost {
                WebHostPhysicalPath = "c:/Windows/Temp"
            }.Init())
            {
                var mock = new HttpRequestMock();

                string originalPath = appHost.WebHostPhysicalPath;
                string path         = mock.GetPhysicalPath();

                var normalizePaths = (Func <string, string>)(p => p == null ? null : p.Replace('\\', '/'));

                Assert.That(normalizePaths(path), Is.EqualTo(normalizePaths("{0}/{1}".Fmt(originalPath, mock.PathInfo))));
            }
        }