public static VirtualPathWrapper Create(string path) { var mi = VirtualPathType.GetMethod("Create", new[] { typeof(string) }); var outObject = new VirtualPathWrapper() { VirtualPath = mi.Invoke(null, new object[] { path }) }; return outObject; }
public static VirtualPathWrapper Create(string path) { var mi = VirtualPathType.GetMethod("Create", new[] { typeof(string) }); var outObject = new VirtualPathWrapper() { VirtualPath = mi.Invoke(null, new object[] { path }) }; return(outObject); }
/// <summary> /// According to referencesource.microsoft.com, this is routed through Request.MapPath, which we expect most testers will by mocking or replacing. /// </summary> /// <param name="path"></param> /// <returns></returns> public override string MapPath(string path) { if (!WebApplicationProxy.IsInitialized) { throw new InvalidOperationException("WebApplicationProxy needs to be initialized before using MapPath"); } // NOTE: YAGNI -- make this a simple implementation that concatenates the two paths var vpath = VirtualPathWrapper.Create(path); // Drop initial slash before we join paths var virtualPathString = vpath.VirtualPathString.Substring(1); return(System.IO.Path.Combine(WebApplicationProxy.WebRootFolder, virtualPathString)); }
/// <summary> /// Add some needed configuration to the HttpRuntime so that it thinks we are running in a Web Service /// </summary> private static void InjectTestValuesIntoHttpRuntime() { var p = typeof(HttpRuntime).GetField("_appDomainAppVPath", BindingFlags.NonPublic | BindingFlags.Instance); p.SetValue(HttpRuntimeInstance, VirtualPathWrapper.Create("/").VirtualPath); }
public TestHttpWorkerRequest(string rawRequestUrl) { _rawRequestUrl = rawRequestUrl; _RequestUri = new Uri((rawRequestUrl.StartsWith("http") ? rawRequestUrl : "http://localhost") + rawRequestUrl); _absoluteUrl = VirtualPathWrapper.CreateAbsolute(VirtualPathUtility.ToAbsolute(rawRequestUrl)); }
public TestHttpWorkerRequest(string rawRequestUrl) { _rawRequestUrl = rawRequestUrl; _RequestUri = new Uri((rawRequestUrl.StartsWith("http") ? rawRequestUrl : "http://localhost") + rawRequestUrl); _absoluteUrl = VirtualPathWrapper.CreateAbsolute(VirtualPathUtility.ToAbsolute(rawRequestUrl)); }