public void MakeRelative6_a() { Assert.AreEqual("directory1", VPU.MakeRelative("/directory1/../", "/directory1")); Assert.AreEqual("", VPU.MakeRelative("/directory1", "/directory1/../")); Assert.AreEqual("./", VPU.MakeRelative("/", "/directory1/../")); Assert.AreEqual("directory1", VPU.MakeRelative("/directory1", "/directory2/../directory1")); }
public void ToAppRelative() { Assert.AreEqual("~/hi", VPU.ToAppRelative("~/hi", null)); Assert.AreEqual("~/hi", VPU.ToAppRelative("~/hi", "")); Assert.AreEqual("~/hi", VPU.ToAppRelative("~/hi", "/..")); Assert.AreEqual("~/hi", VPU.ToAppRelative("~/hi", "me")); Assert.AreEqual("~", VPU.ToAppRelative("~", "/ROOT")); Assert.AreEqual("~/", VPU.ToAppRelative("~/", "/ROOT")); Assert.AreEqual("~/blah", VPU.ToAppRelative("~/blah", "/ROOT/")); Assert.AreEqual("~/blah2/", VPU.ToAppRelative("~/blah1/../blah2/", "/ROOT/")); Assert.AreEqual("~/", VPU.ToAppRelative("/ROOT", "/ROOT")); Assert.AreEqual("~/", VPU.ToAppRelative("/ROOT/", "/ROOT")); Assert.AreEqual("~/blah/blah/", VPU.ToAppRelative("/ROOT/blah//blah//", "/ROOT")); Assert.AreEqual("~/blah/blah/", VPU.ToAppRelative("/ROOT/blah\\blah/", "/ROOT")); Assert.AreEqual("~/blah2/", VPU.ToAppRelative("/ROOT/blah1/../blah2/", "/ROOT")); Assert.AreEqual("~/blah1/blah2/", VPU.ToAppRelative("/ROOT/blah1/./blah2/", "/ROOT")); Assert.AreEqual("~/blah1", VPU.ToAppRelative("/ROOT/blah1/blah2/..", "/ROOT")); Assert.AreEqual("~/", VPU.ToAppRelative("/ROOT/blah1/..", "/ROOT")); Assert.AreEqual("~/blah1/", VPU.ToAppRelative("/ROOT/blah1/blah2/../", "/ROOT")); Assert.AreEqual("~/", VPU.ToAppRelative("/ROOT/blah1/../", "/ROOT")); Assert.AreEqual("~/blah1", VPU.ToAppRelative("/ROOT/blah1/.", "/ROOT")); Assert.AreEqual("~/", VPU.ToAppRelative("/ROOT/.", "/ROOT")); Assert.AreEqual("~/blah1/", VPU.ToAppRelative("/ROOT/blah1/./", "/ROOT")); Assert.AreEqual("~/", VPU.ToAppRelative("/ROOT/./", "/ROOT")); Assert.AreEqual("~/ROOT", VPU.ToAppRelative("/ROOT", "/")); Assert.AreEqual("~/ROOT", VPU.ToAppRelative("/ROOT", "/hi/..")); Assert.AreEqual("~/ROOT", VPU.ToAppRelative("/ROOT/hi/..", "/")); }
public void AppendTrailingSlash() { Assert.AreEqual("/hithere/", VPU.AppendTrailingSlash("/hithere"), "A1"); Assert.AreEqual("/hithere/", VPU.AppendTrailingSlash("/hithere/"), "A2"); Assert.AreEqual("/", VPU.AppendTrailingSlash("/"), "A3"); Assert.AreEqual("", VPU.AppendTrailingSlash(""), "A4"); Assert.AreEqual(null, VPU.AppendTrailingSlash(null), "A5"); }
public void RemoveTrailingSlash() { Assert.AreEqual("/hi/there", VPU.RemoveTrailingSlash("/hi/there/"), "A1"); Assert.AreEqual("/hi/there", VPU.RemoveTrailingSlash("/hi/there"), "A2"); Assert.AreEqual("/", VPU.RemoveTrailingSlash("/"), "A3"); Assert.AreEqual(null, VPU.RemoveTrailingSlash(""), "A4"); Assert.AreEqual(null, VPU.RemoveTrailingSlash(null), "A5"); }
public void ToAbsolute8_b() { Assert.AreEqual("/blah2/", VPU.ToAbsolute("/blah1/../blah2/")); Assert.AreEqual("/blah2/", VPU.ToAbsolute("/blah1//../blah2/")); Assert.AreEqual("/blah2/", VPU.ToAbsolute("/blah1/\\../blah2/")); Assert.AreEqual("/blah2/", VPU.ToAbsolute("/blah1\\\\../blah2/")); Assert.AreEqual("/blah1/blah2/", VPU.ToAbsolute("/blah1/./blah2/")); }
public void GetFileName1() { Assert.AreEqual("", VPU.GetFileName("/")); Assert.AreEqual("hola", VPU.GetFileName("/hola")); Assert.AreEqual("hola", VPU.GetFileName("/hola/")); Assert.AreEqual("hi", VPU.GetFileName("/hi/there/..")); Assert.AreEqual("there", VPU.GetFileName("/hi/there/.")); }
public void RemoveTrailingSlash2() { Assert.AreEqual(null, VPU.RemoveTrailingSlash(null)); Assert.AreEqual(null, VPU.RemoveTrailingSlash("")); Assert.AreEqual("/", VPU.RemoveTrailingSlash("/")); Assert.AreEqual("////", VPU.RemoveTrailingSlash("/////")); Assert.AreEqual("/pepe", VPU.RemoveTrailingSlash("/pepe")); Assert.AreEqual("/pepe", VPU.RemoveTrailingSlash("/pepe/")); }
public static IHtmlString ScriptBundle(this HtmlHelper helper, string bundleKey) { if (helper == null) { throw new ArgumentNullException("helper"); } if (String.IsNullOrEmpty(bundleKey)) { throw new ArgumentNullException("bundleKey"); } var context = helper.ViewContext.HttpContext; if (!ScriptBundleManager.IsEnabled) { StringBuilder sb = new StringBuilder(); foreach (var include in ScriptBundleManager.GetBundleIncludes(bundleKey)) { var scriptUrl = include; if (string.IsNullOrEmpty(scriptUrl)) { continue; } if (scriptUrl != null && scriptUrl.StartsWith("dynamic://", StringComparison.OrdinalIgnoreCase)) { var scriptName = scriptUrl.Substring(10); scriptUrl = DynamicScriptManager.GetScriptInclude(scriptName); scriptUrl = VirtualPathUtility.ToAbsolute("~/DynJS.axd/" + scriptUrl); } else { scriptUrl = BundleUtils.ExpandVersionVariable(scriptUrl); scriptUrl = VirtualPathUtility.ToAbsolute(scriptUrl); } var scripts = GetIncludedScripts(context); if (!scripts.Contains(scriptUrl)) { scripts.Add(scriptUrl); sb.AppendLine(String.Format(" <script src=\"{0}\" type=\"text/javascript\"></script>\n", #if !ASPNETMVC WebUtility.HtmlEncode(ContentHashCache.ResolveWithHash(scriptUrl)))); #else HttpUtility.HtmlAttributeEncode(ContentHashCache.ResolveWithHash(scriptUrl)))); #endif } } return(new HtmlString(sb.ToString())); } return(Script(helper, "dynamic://Bundle." + bundleKey)); }
public static IHtmlString StyleBundle(this HtmlHelper helper, string bundleKey) { if (helper == null) { throw new ArgumentNullException("helper"); } if (String.IsNullOrEmpty(bundleKey)) { throw new ArgumentNullException("bundleKey"); } var context = helper.ViewContext.HttpContext; if (!CssBundleManager.IsEnabled) { StringBuilder sb = new StringBuilder(); foreach (var include in CssBundleManager.GetBundleIncludes(bundleKey)) { var cssUrl = include; if (string.IsNullOrEmpty(cssUrl)) { continue; } if (cssUrl != null && cssUrl.StartsWith("dynamic://", StringComparison.OrdinalIgnoreCase)) { var scriptName = cssUrl.Substring(10); cssUrl = DynamicScriptManager.GetScriptInclude(scriptName, ".css"); cssUrl = VirtualPathUtility.ToAbsolute("~/DynJS.axd/" + cssUrl); } else { cssUrl = BundleUtils.ExpandVersionVariable(cssUrl); cssUrl = VirtualPathUtility.ToAbsolute(cssUrl); } var cssList = GetIncludedCssList(context); if (!cssList.Contains(cssUrl)) { cssList.Add(cssUrl); sb.AppendLine(String.Format(" <link href=\"{0}\" rel=\"stylesheet\" type=\"text/css\"/>\n", #if !ASPNETMVC WebUtility.HtmlEncode(ContentHashCache.ResolveWithHash(cssUrl)))); #else HttpUtility.HtmlAttributeEncode(ContentHashCache.ResolveWithHash(cssUrl)))); #endif } } return(new HtmlString(sb.ToString())); } return(Stylesheet(helper, "dynamic://CssBundle." + bundleKey)); }
public void IsAbsolute() { Assert.IsTrue(VPU.IsAbsolute("/"), "A1"); Assert.IsTrue(VPU.IsAbsolute("/hi/there"), "A2"); Assert.IsFalse(VPU.IsAbsolute("hi/there"), "A3"); Assert.IsFalse(VPU.IsAbsolute("./hi"), "A4"); Assert.IsTrue(VPU.IsAbsolute("\\"), "A1"); Assert.IsTrue(VPU.IsAbsolute("\\hi\\there"), "A2"); Assert.IsFalse(VPU.IsAbsolute("hi\\there"), "A3"); Assert.IsFalse(VPU.IsAbsolute(".\\hi"), "A4"); }
public void MakeRelative6() { Assert.AreEqual("./", VPU.MakeRelative("/", "/")); Assert.AreEqual("directory1", VPU.MakeRelative("/directory1", "/directory1")); Assert.AreEqual("directory2", VPU.MakeRelative("/directory1", "/directory2")); Assert.AreEqual("directory1", VPU.MakeRelative("/", "/directory1")); Assert.AreEqual("", VPU.MakeRelative("/directory1", "/")); Assert.AreEqual("./", VPU.MakeRelative("/directory1/", "/directory1/")); Assert.AreEqual("directory1/file1.aspx", VPU.MakeRelative("/directory1", "/directory1/file1.aspx")); Assert.AreEqual("file1.aspx", VPU.MakeRelative("/directory1/file1.aspx", "/directory1/file1.aspx")); Assert.AreEqual("file1.aspx", VPU.MakeRelative("/directory1/", "/directory1/file1.aspx")); Assert.AreEqual("../directory2/file2.aspx", VPU.MakeRelative("/directory1/file1.aspx", "/directory2/file2.aspx")); }
public static void GetFileName4_Load(Page p) { Assert.AreEqual(NunitWebAppName, VPU.GetFileName("~/")); Assert.AreEqual("hola", VPU.GetFileName("~/hola")); Assert.AreEqual("hola", VPU.GetFileName("~/hola/")); Assert.AreEqual("hi", VPU.GetFileName("~/hi/there/..")); Assert.AreEqual("there", VPU.GetFileName("~/hi/there/.")); Assert.AreEqual(NunitWebAppName, VPU.GetFileName("~")); Assert.AreEqual("", VPU.GetFileName("~/..")); Assert.AreEqual("", VPU.GetFileName("~/../")); Assert.AreEqual("hi", VPU.GetFileName("~/../hi")); Assert.AreEqual("hi", VPU.GetFileName("~/../hi/")); }
public void Combine() { Assert.AreEqual("/there", VPU.Combine("/hi", "there"), "A1"); Assert.AreEqual("/hi/you", VPU.Combine("/hi/there", "you"), "A2"); Assert.AreEqual("/hi/there/you", VPU.Combine("/hi/there/", "you"), "A3"); Assert.AreEqual("/there/", VPU.Combine("/hi", "there/"), "A1"); Assert.AreEqual("/hi/you/", VPU.Combine("/hi/there", "you/"), "A2"); Assert.AreEqual("/hi/there/you/", VPU.Combine("/hi/there/", "you/"), "A3"); Assert.AreEqual("/there", VPU.Combine("/hi", "/there"), "A1"); Assert.AreEqual("/you", VPU.Combine("/hi/there", "/you"), "A2"); Assert.AreEqual("/you", VPU.Combine("/hi/there/", "/you"), "A3"); }
/// <summary> Gets the <see cref="Type"/> for the specified <paramref name="absolutePath"/>. </summary> /// <include file='..\doc\include\ExecutionEngine\WxeHandler.xml' path='WxeHandler/GetTypeByPath/*' /> protected virtual Type GetTypeByPath(string absolutePath) { ArgumentUtility.CheckNotNullOrEmpty("absolutePath", absolutePath); string relativePath = VirtualPathUtility.ToAppRelative(absolutePath); Type type = UrlMapping.UrlMappingConfiguration.Current.Mappings.FindType(relativePath); if (type == null) { throw new WxeException(string.Format("Could not map the path '{0}' to a WXE function.", absolutePath)); } return(type); }
public void IsAppRelative() { Assert.IsTrue(VPU.IsAppRelative("~"), "A0"); Assert.IsTrue(VPU.IsAppRelative("~/Stuff"), "A1"); Assert.IsFalse(VPU.IsAppRelative("./Stuff"), "A2"); Assert.IsFalse(VPU.IsAppRelative("/Stuff"), "A3"); Assert.IsFalse(VPU.IsAppRelative("/"), "A4"); Assert.IsFalse(VPU.IsAppRelative("~Stuff"), "A5"); Assert.IsTrue(VPU.IsAppRelative("~"), "A0"); Assert.IsTrue(VPU.IsAppRelative("~\\Stuff"), "A1"); Assert.IsFalse(VPU.IsAppRelative(".\\Stuff"), "A2"); Assert.IsFalse(VPU.IsAppRelative("\\Stuff"), "A3"); Assert.IsFalse(VPU.IsAppRelative("\\"), "A4"); Assert.IsFalse(VPU.IsAppRelative("~Stuff"), "A5"); }
public void Combine3() { Assert.AreEqual("/", VPU.Combine("/hi/", ".."), "A1"); Assert.AreEqual("/", VPU.Combine("/hi/there", ".."), "A2"); Assert.AreEqual("/hi", VPU.Combine("/hi/there/", ".."), "A3"); Assert.AreEqual("/", VPU.Combine("/hi/", "../"), "A1"); Assert.AreEqual("/", VPU.Combine("/hi/there", "../"), "A2"); Assert.AreEqual("/hi/", VPU.Combine("/hi/there/", "../"), "A3"); Assert.AreEqual("/", VPU.Combine("/", "."), "A1"); Assert.AreEqual("/", VPU.Combine("/hi", "."), "A2"); Assert.AreEqual("/hi", VPU.Combine("/hi/", "."), "A3"); Assert.AreEqual("/", VPU.Combine("/", "./"), "A1"); Assert.AreEqual("/", VPU.Combine("/hi", "./"), "A2"); Assert.AreEqual("/hi/", VPU.Combine("/hi/", "./"), "A3"); Assert.AreEqual("/", VPU.Combine("/hi", "there/../"), "A1"); Assert.AreEqual("/hi", VPU.Combine("/hi/there", "you/.."), "A2"); Assert.AreEqual("/there/", VPU.Combine("/hi", "there/./"), "A1"); Assert.AreEqual("/hi/you", VPU.Combine("/hi/there", "you/."), "A2"); Assert.AreEqual("/blah2/", VPU.Combine("/ROOT", "/blah1/../blah2/")); Assert.AreEqual("/blah1/blah2/", VPU.Combine("/ROOT", "/blah1/./blah2/")); Assert.AreEqual("/blah1", VPU.Combine("/ROOT", "/blah1/blah2/..")); Assert.AreEqual("/", VPU.Combine("/ROOT", "/blah1/..")); Assert.AreEqual("/blah1/", VPU.Combine("/ROOT", "/blah1/blah2/../")); Assert.AreEqual("/", VPU.Combine("/ROOT", "/blah1/../")); Assert.AreEqual("/blah1", VPU.Combine("/ROOT", "/blah1/.")); Assert.AreEqual("/", VPU.Combine("/ROOT", "/.")); Assert.AreEqual("/blah1/", VPU.Combine("/ROOT", "/blah1/./")); Assert.AreEqual("/", VPU.Combine("/ROOT", "/./")); Assert.AreEqual("/", VPU.Combine("///hi/", ".."), "A1"); Assert.AreEqual("/", VPU.Combine("/hi/there/me/..", ".."), "A1"); Assert.AreEqual("/", VPU.Combine("/hi/there/../", ".."), "A1"); Assert.AreEqual("/hi/me", VPU.Combine("/hi/there/../", "me"), "A1"); Assert.AreEqual("/", VPU.Combine("/hi/there/../you", ".."), "A1"); Assert.AreEqual("/hi/me", VPU.Combine("/hi/there/../you", "me"), "A1"); Assert.AreEqual("/hi/you/me", VPU.Combine("/hi/there/../you/", "me"), "A1"); }
public static void Combine4_Load(Page p) { Assert.AreEqual("~", VPU.Combine("/ROOT", "~"), "/ROOT, ~"); Assert.AreEqual("~/blah1", VPU.Combine("/ROOT", "~/blah1"), "/ROOT, ~/blah1"); Assert.AreEqual("~/blah1/", VPU.Combine("/ROOT", "~/blah1/")); Assert.AreEqual("~/blah2/", VPU.Combine("/ROOT", "~/blah1/../blah2/")); Assert.AreEqual("~/blah1/blah2/", VPU.Combine("/ROOT", "~/blah1/./blah2/")); Assert.AreEqual("~/blah1", VPU.Combine("/ROOT", "~/blah1/blah2/..")); Assert.AreEqual("~", VPU.Combine("/ROOT", "~/blah1/..")); Assert.AreEqual("~/blah1/", VPU.Combine("/ROOT", "~/blah1/blah2/../")); Assert.AreEqual("~/", VPU.Combine("/ROOT", "~/blah1/../")); Assert.AreEqual("~/blah1", VPU.Combine("/ROOT", "~/blah1/.")); Assert.AreEqual("~", VPU.Combine("/ROOT", "~/.")); Assert.AreEqual("~/blah1/", VPU.Combine("/ROOT", "~/blah1/./")); Assert.AreEqual("~/", VPU.Combine("/ROOT", "~/./")); Assert.AreEqual("/", VPU.Combine("~/ROOT", "~/.."), "~/ROOT, ~/.."); Assert.AreEqual("/", VPU.Combine("~/ROOT", "..")); Assert.AreEqual("~", VPU.Combine("~/ROOT/", "..")); Assert.AreEqual("~/", VPU.Combine("~/ROOT/", "../")); Assert.AreEqual("~/folder", VPU.Combine("~/ROOT", "folder")); Assert.AreEqual("~/ROOT/folder", VPU.Combine("~/ROOT/", "folder")); Assert.AreEqual("~/ROOT/folder/", VPU.Combine("~/ROOT/", "folder/")); Assert.AreEqual("/", VPU.Combine("~", "..")); Assert.AreEqual("~/me", VPU.Combine("~", "me")); Assert.AreEqual("/me", VPU.Combine("~", "../me")); Assert.AreEqual("~/me", VPU.Combine("~", "./me")); Assert.AreEqual("/me", VPU.Combine("~/..", "me")); Assert.AreEqual("/", VPU.Combine("~/hi/there/..", ".."), "A1"); Assert.AreEqual("~", VPU.Combine("~/hi/there/../", ".."), "A1"); Assert.AreEqual("/", VPU.Combine("~/hi/there/../", "../.."), "A1"); Assert.AreEqual("~/hi/me", VPU.Combine("~/hi/there/../", "me"), "A1"); Assert.AreEqual("~", VPU.Combine("~/hi/there/../you", ".."), "A1"); Assert.AreEqual("~/hi/me", VPU.Combine("~/hi/there/../you", "me"), "A1"); Assert.AreEqual("~/hi/you/me", VPU.Combine("~/hi/there/../you/", "me"), "A1"); Assert.AreEqual(HttpRuntime.AppDomainAppVirtualPath, VPU.Combine("/ROOT", HttpRuntime.AppDomainAppVirtualPath)); Assert.AreEqual(HttpRuntime.AppDomainAppVirtualPath, VPU.Combine("~/ROOT", HttpRuntime.AppDomainAppVirtualPath)); }
public void ToAbsolute8_a() { Assert.AreEqual("/blah2/", VPU.ToAbsolute("/blah1/../blah2/", "/ROOT")); Assert.AreEqual("/blah2/", VPU.ToAbsolute("/blah1//../blah2/", "/ROOT")); Assert.AreEqual("/blah2/", VPU.ToAbsolute("/blah1/\\../blah2/", "/ROOT")); Assert.AreEqual("/blah2/", VPU.ToAbsolute("/blah1\\\\../blah2/", "/ROOT")); Assert.AreEqual("/blah1/blah2/", VPU.ToAbsolute("/blah1/./blah2/", "/ROOT")); Assert.AreEqual("/blah1", VPU.ToAbsolute("/blah1/blah2/..", "/ROOT")); Assert.AreEqual("/", VPU.ToAbsolute("/blah1/..", "/ROOT")); Assert.AreEqual("/blah1/", VPU.ToAbsolute("/blah1/blah2/../", "/ROOT")); Assert.AreEqual("/", VPU.ToAbsolute("/blah1/../", "/ROOT")); Assert.AreEqual("/blah1", VPU.ToAbsolute("/blah1/.", "/ROOT")); Assert.AreEqual("/", VPU.ToAbsolute("/.", "/ROOT")); Assert.AreEqual("/blah1/", VPU.ToAbsolute("/blah1/./", "/ROOT")); Assert.AreEqual("/", VPU.ToAbsolute("/./", "/ROOT")); }
public void GetExtension() { Assert.AreEqual(".aspx", VPU.GetExtension("/hi/index.aspx"), "A1"); Assert.AreEqual("", VPU.GetExtension("/hi/index.aspx/"), "A1"); Assert.AreEqual(".aspx", VPU.GetExtension("index.aspx"), "A2"); Assert.AreEqual("", VPU.GetExtension("/hi/index"), "A3"); Assert.AreEqual(".aspx", VPU.GetExtension("/hi/./index.aspx"), "A1"); Assert.AreEqual("", VPU.GetExtension("hi/index"), "A2"); Assert.AreEqual("", VPU.GetExtension("/hi/index.aspx/file"), "A1"); Assert.AreEqual("", VPU.GetExtension("/hi/index.aspx\\file"), "A1"); Assert.AreEqual("", VPU.GetExtension("/hi/index.aspx/../file"), "A1"); Assert.AreEqual(".htm", VPU.GetExtension("/hi/index.aspx/../file.htm"), "A1"); Assert.AreEqual("", VPU.GetExtension(".."), "A2"); Assert.AreEqual("", VPU.GetExtension("../.."), "A2"); Assert.AreEqual(".aspx", VPU.GetExtension("../../file.aspx"), "A2"); }
public static void GetDirectory5_Load(Page p) { Assert.AreEqual("~/direc/", VPU.GetDirectory("~/direc/somefilenoextension")); Assert.AreEqual("~/direc/", VPU.GetDirectory("~/direc/somefile.aspx")); Assert.AreEqual("~/direc/", VPU.GetDirectory("~/////direc///somefile.aspx")); Assert.AreEqual("~/direc/", VPU.GetDirectory("~\\\\direc\\///somefile.aspx")); Assert.AreEqual("~/direc/", VPU.GetDirectory("~/direc/somefilenoextension/")); Assert.AreEqual("/", VPU.GetDirectory("~/"), "~/"); Assert.AreEqual("/", VPU.GetDirectory("~"), "~"); Assert.AreEqual("/", VPU.GetDirectory("~/dir1/.."), "/dir1/.."); Assert.AreEqual("/", VPU.GetDirectory("~/dir1/../"), "/dir1/../"); Assert.AreEqual("~/", VPU.GetDirectory("~/dir1/../dir2"), "/dir1/../dir2"); Assert.AreEqual("~/", VPU.GetDirectory("~/dir1/../dir2/"), "/dir1/../dir2/"); Assert.AreEqual("~/dir2/", VPU.GetDirectory("~/dir1/../dir2/somefile.aspx")); Assert.AreEqual("/dir1/", VPU.GetDirectory("~/../dir1/dir2"), "~/../dir1"); Assert.AreEqual("/dir1/", VPU.GetDirectory("~/../dir1/dir2/"), "~/../dir1/"); }
public void GetDirectory4() { Assert.AreEqual("/direc/", VPU.GetDirectory("/direc/somefilenoextension")); Assert.AreEqual("/direc/", VPU.GetDirectory("/direc/somefile.aspx")); Assert.AreEqual("/direc/", VPU.GetDirectory("/////direc///somefile.aspx")); Assert.AreEqual("/direc/", VPU.GetDirectory("\\\\direc\\///somefile.aspx")); Assert.AreEqual("/direc/", VPU.GetDirectory("/direc/somefilenoextension/")); Assert.AreEqual(null, VPU.GetDirectory("/"), "A3"); Assert.AreEqual(null, VPU.GetDirectory("/dir1/.."), "/dir1/.."); Assert.AreEqual(null, VPU.GetDirectory("/dir1/../"), "/dir1/../"); Assert.AreEqual("/", VPU.GetDirectory("/dir1/../dir2"), "/dir1/../dir2"); Assert.AreEqual("/", VPU.GetDirectory("/dir1/../dir2/"), "/dir1/../dir2/"); Assert.AreEqual("/dir2/", VPU.GetDirectory("/dir1/../dir2/somefile.aspx")); Assert.AreEqual("~/direc/", VPU.GetDirectory("~/direc/somefilenoextension")); Assert.AreEqual("~/direc/", VPU.GetDirectory("~/direc/somefile.aspx")); Assert.AreEqual("~/direc/", VPU.GetDirectory("~/////direc///somefile.aspx")); Assert.AreEqual("~/direc/", VPU.GetDirectory("~\\\\direc\\///somefile.aspx")); Assert.AreEqual("~/direc/", VPU.GetDirectory("~/direc/somefilenoextension/")); }
public static void MakeRelative7_Load(Page p) { Assert.AreEqual("./", VPU.MakeRelative("~", "~"), "~, ~"); Assert.AreEqual("./", VPU.MakeRelative("~/", "~/")); Assert.AreEqual("./", VPU.MakeRelative("~//", "~//")); Assert.AreEqual("./", VPU.MakeRelative("~", "~//"), "~, ~//"); Assert.AreEqual("directory1", VPU.MakeRelative("~/directory1", "~/directory1")); Assert.AreEqual("directory2", VPU.MakeRelative("~/directory1", "~/directory2")); Assert.AreEqual("directory1", VPU.MakeRelative("~/", "~/directory1")); Assert.AreEqual("", VPU.MakeRelative("~/directory1", "~/")); Assert.AreEqual("./", VPU.MakeRelative("~/directory1/", "~/directory1/")); Assert.AreEqual("directory1/file1.aspx", VPU.MakeRelative("~/directory1", "~/directory1/file1.aspx")); Assert.AreEqual("file1.aspx", VPU.MakeRelative("~/directory1/", "~/directory1/file1.aspx")); Assert.AreEqual("../directory2/file2.aspx", VPU.MakeRelative("~/directory1/file1.aspx", "~/directory2/file2.aspx")); Assert.AreEqual("directory1", VPU.MakeRelative("~/directory1/../", "~/directory1")); Assert.AreEqual("", VPU.MakeRelative("~/directory1", "~/directory1/../")); Assert.AreEqual("./", VPU.MakeRelative("~/", "~/directory1/../")); Assert.AreEqual("directory1", VPU.MakeRelative("~/directory1", "~/directory2/../directory1")); Assert.AreEqual("../", VPU.MakeRelative("~", "/")); Assert.AreEqual("NunitWeb/", VPU.MakeRelative("/", "~")); }
public void ToAbsolute13() { Assert.AreEqual("/blah", VPU.ToAbsolute("/blah", "ROOT")); }
public void ToAbsolute11() { VPU.ToAbsolute("blah", "/ROOT"); }
public void ToAbsolute12() { VPU.ToAbsolute("~/blah", "ROOT"); }
public void ToAbsolute10() { VPU.ToAbsolute("../blah", "/ROOT"); }
public void ToAppRelative_Exc8() { VPU.ToAppRelative("/../ROOT/hi", "/ROOT"); }
//The relative virtual path 'hi' is not allowed here. public void ToAppRelative_Exc7_a() { VPU.ToAppRelative("hi", null); }
//The relative virtual path 'hi' is not allowed here. public void ToAppRelative_Exc7() { VPU.ToAppRelative("hi", "/ROOT"); }
public void ToAppRelative_Exc6() { VPU.ToAppRelative("", "/ROOT"); }