public void GetAbsoluteApplication() { //Arrange string path = AppDomain.CurrentDomain.BaseDirectory; const string virtualDir = "/app"; AppDomain.CurrentDomain.SetData(".appDomain", "*"); AppDomain.CurrentDomain.SetData(".appPath", path); AppDomain.CurrentDomain.SetData(".appVPath", virtualDir); AppDomain.CurrentDomain.SetData(".hostingVirtualPath", virtualDir); AppDomain.CurrentDomain.SetData(".hostingInstallDir", HttpRuntime.AspInstallDirectory); var request = new Mock <HttpRequestBase>(); request.SetupGet(x => x.Url).Returns(() => { return(new Uri("http://www.gameball.com.tw/")); }); //var path = new Mock<IVirtualPathUtility>(); //path.Setup(x => x.ToAbsolute("~")).Returns("/app"); string expected = "http://www.gameball.com.tw/app"; //Act RequestWrapper wrapper = new RequestWrapper(request.Object); string result = wrapper.GetAbsoluteApplication(); //Assert Assert.AreEqual(expected, result); }