-//
-// System.Web.VirtualPathUtility.cs
-//
-// Author:
-// Chris Toshok (toshok@ximian.com)
-// Gonzalo Paniagua Javier (gonzalo@ximian.com)
-//
-
-//
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if NET_2_0
-
-using System.Web.Util;
-
-namespace System.Web {
-
- public static class VirtualPathUtility
- {
- public static string AppendTrailingSlash (string virtualPath)
- {
- if (virtualPath == null)
- return virtualPath;
-
- int length = virtualPath.Length;
- if (length == 0 || virtualPath [length - 1] == '/')
- return virtualPath;
-
- return virtualPath + "/";
- }
-
- public static string Combine (string basePath, string relativePath)
- {
- if (basePath == null || basePath == "")
- throw new ArgumentNullException ("basePath");
-
- if (relativePath == null || relativePath == "")
- throw new ArgumentNullException ("relativePath");
-
- if (basePath [0] != '/')
- throw new ArgumentException ("basePath is not an absolute path", "basePath");
-
- if (relativePath [0] != '/')
- return "/" + relativePath;
-
- return UrlUtils.Combine (basePath, relativePath);
- }
-
- public static string GetDirectory (string virtualPath)
- {
- if (virtualPath == null || virtualPath == "") // Yes, "" throws an ArgumentNullException
- throw new ArgumentNullException ("virtualPath");
-
- if (virtualPath [0] != '/')
- throw new ArgumentException ("The virtual path is not rooted", "virtualPath");
-
- string result = UrlUtils.GetDirectory (virtualPath);
- return AppendTrailingSlash (result);
- }
-
- public static string GetExtension (string virtualPath)
- {
- string filename = GetFileName (virtualPath);
- int dot = filename.LastIndexOf ('.');
- if (dot == -1 || dot == filename.Length + 1)
- return "";
-
- return filename.Substring (dot);
- }
-
- public static string GetFileName (string virtualPath)
- {
- if (virtualPath == null || virtualPath == "") // Yes, "" throws an ArgumentNullException
- throw new ArgumentNullException ("virtualPath");
-
- return UrlUtils.GetFile (RemoveTrailingSlash (virtualPath));
- }
-
- public static bool IsAbsolute (string virtualPath)
- {
- if (virtualPath == "" || virtualPath == null)
- throw new ArgumentNullException ("virtualPath");
-
- return (virtualPath [0] == '/');
- }
-
- public static bool IsAppRelative (string virtualPath)
- {
- if (virtualPath == null || virtualPath == "")
- throw new ArgumentNullException ("virtualPath");
-
- string vpath = HttpRuntime.AppDomainAppVirtualPath;
- if (vpath == null)
- return false;
-
- return virtualPath.StartsWith (AppendTrailingSlash (vpath));
- }
-
- public static string MakeRelative (string fromPath, string toPath)
- {
- if (fromPath == null || toPath == null)
- throw new NullReferenceException (); // yeah!
-
- if (toPath == "")
- return toPath;
-
- if (toPath [0] != '/')
- throw new ArgumentOutOfRangeException (); // This is what MS does.
-
- if (fromPath.Length > 0 && fromPath [0] != '/')
- throw new ArgumentOutOfRangeException (); // This is what MS does.
-
- Uri from = new Uri ("http://nothing" + fromPath);
- return from.MakeRelativeUri (new Uri ("http://nothing" + toPath)).AbsolutePath;
- }
-
- public static string RemoveTrailingSlash (string virtualPath)
- {
- if (virtualPath == null || virtualPath == "")
- return null;
-
- int last = virtualPath.Length - 1;
- if (last == 0 || virtualPath [last] != '/')
- return virtualPath;
-
- return virtualPath.Substring (0, last);
- }
-
- public static string ToAbsolute (string virtualPath)
- {
- string apppath = HttpRuntime.AppDomainAppVirtualPath;
- if (apppath == null)
- throw new HttpException ("The path to the application is not known");
-
- return ToAbsolute (virtualPath,apppath);
- }
-
- // If virtualPath is:
- // Absolute, the ToAbsolute method returns the virtual path with no changes.
- // Application relative, the ToAbsolute method adds applicationPath to the beginning of the virtual path.
- // Not rooted, the ToAbsolute method raises an ArgumentOutOfRangeException exception.
- public static string ToAbsolute (string virtualPath, string applicationPath)
- {
- if (applicationPath == null || applicationPath == "")
- throw new ArgumentNullException ("applicationPath");
-
- if (virtualPath == null || virtualPath == "")
- throw new ArgumentNullException ("virtualPath");
-
- if (virtualPath.Length > 1 && virtualPath [0] == '~' && virtualPath [1] == '/') {
- if (applicationPath [0] != '/')
- throw new ArgumentException ("appPath is not rooted", "applicationPath");
- return UrlUtils.RemoveDoubleSlashes ((applicationPath + virtualPath.Substring (1)).Replace ('\\', '/'));
- }
-
- if (virtualPath [0] != '/')
- throw new ArgumentException (String.Format ("Relative path not allowed: '{0}'", virtualPath));
-
- return UrlUtils.RemoveDoubleSlashes (virtualPath.Replace ('\\', '/'));
-
- }
-
- public static string ToAppRelative (string virtualPath)
- {
- string apppath = HttpRuntime.AppDomainAppVirtualPath;
- if (apppath == null)
- throw new HttpException ("The path to the application is not known");
-
- return ToAppRelative (apppath, virtualPath);
- }
-
- public static string ToAppRelative (string virtualPath, string applicationPath)
- {
- if (applicationPath == null || applicationPath == "")
- throw new ArgumentNullException ("applicationPath");
-
- if (virtualPath == null || virtualPath == "")
- throw new ArgumentNullException ("virtualPath");
-
- if (virtualPath.StartsWith (".."))
- throw new ArgumentException (String.Format ("Relative path not allowed: '{0}'", virtualPath));
-
- if (applicationPath [0] != '/')
- throw new ArgumentOutOfRangeException ("appPath is not rooted", "applicationPath");
-
- return MakeRelative (applicationPath, virtualPath);
- }
- }
-}
-
-#endif
-
+//\r
+// System.Web.VirtualPathUtility.cs\r
+//\r
+// Author:\r
+// Chris Toshok (toshok@ximian.com)\r
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)\r
+//\r
+\r
+//\r
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+#if NET_2_0\r
+\r
+using System.Web.Util;\r
+\r
+namespace System.Web {\r
+\r
+ public static class VirtualPathUtility\r
+ {\r
+ public static string AppendTrailingSlash (string virtualPath)\r
+ {\r
+ if (virtualPath == null)\r
+ return virtualPath;\r
+\r
+ int length = virtualPath.Length;\r
+ if (length == 0 || virtualPath [length - 1] == '/')\r
+ return virtualPath;\r
+\r
+ return virtualPath + "/";\r
+ }\r
+\r
+ public static string Combine (string basePath, string relativePath)\r
+ {\r
+ if (basePath == null || basePath == "")\r
+ throw new ArgumentNullException ("basePath");\r
+\r
+ if (relativePath == null || relativePath == "")\r
+ throw new ArgumentNullException ("relativePath");\r
+\r
+ if (basePath [0] != '/')\r
+ throw new ArgumentException ("basePath is not an absolute path", "basePath");\r
+\r
+ if (relativePath [0] != '/')\r
+ return "/" + relativePath;\r
+\r
+ return UrlUtils.Combine (basePath, relativePath);\r
+ }\r
+\r
+ public static string GetDirectory (string virtualPath)\r
+ {\r
+ if (virtualPath == null || virtualPath == "") // Yes, "" throws an ArgumentNullException\r
+ throw new ArgumentNullException ("virtualPath");\r
+\r
+ if (virtualPath [0] != '/')\r
+ throw new ArgumentException ("The virtual path is not rooted", "virtualPath");\r
+\r
+ string result = UrlUtils.GetDirectory (virtualPath);\r
+ return AppendTrailingSlash (result);\r
+ }\r
+\r
+ public static string GetExtension (string virtualPath)\r
+ {\r
+ string filename = GetFileName (virtualPath);\r
+ int dot = filename.LastIndexOf ('.');\r
+ if (dot == -1 || dot == filename.Length + 1)\r
+ return "";\r
+\r
+ return filename.Substring (dot);\r
+ }\r
+\r
+ public static string GetFileName (string virtualPath)\r
+ {\r
+ if (virtualPath == null || virtualPath == "") // Yes, "" throws an ArgumentNullException\r
+ throw new ArgumentNullException ("virtualPath");\r
+ \r
+ return UrlUtils.GetFile (RemoveTrailingSlash (virtualPath));\r
+ }\r
+\r
+ public static bool IsAbsolute (string virtualPath)\r
+ {\r
+ if (virtualPath == "" || virtualPath == null)\r
+ throw new ArgumentNullException ("virtualPath");\r
+\r
+ return (virtualPath [0] == '/');\r
+ }\r
+\r
+ public static bool IsAppRelative (string virtualPath)\r
+ {\r
+ if (String.IsNullOrEmpty (virtualPath))\r
+ throw new ArgumentNullException ("virtualPath");\r
+\r
+ if (virtualPath.Length == 1 && virtualPath [0] == '~')\r
+ return true;\r
+\r
+ if (virtualPath [0] == '~' && virtualPath [1] == '/')\r
+ return true;\r
+\r
+ return false;\r
+ }\r
+\r
+ public static string MakeRelative (string fromPath, string toPath)\r
+ {\r
+ if (fromPath == null || toPath == null)\r
+ throw new NullReferenceException (); // yeah!\r
+\r
+ if (toPath == "")\r
+ return toPath;\r
+\r
+ if (toPath [0] != '/')\r
+ throw new ArgumentOutOfRangeException (); // This is what MS does.\r
+\r
+ if (fromPath.Length > 0 && fromPath [0] != '/')\r
+ throw new ArgumentOutOfRangeException (); // This is what MS does.\r
+\r
+ Uri from = new Uri ("http://nothing" + fromPath);\r
+ return from.MakeRelativeUri (new Uri ("http://nothing" + toPath)).AbsolutePath;\r
+ }\r
+\r
+ public static string RemoveTrailingSlash (string virtualPath)\r
+ {\r
+ if (virtualPath == null || virtualPath == "")\r
+ return null;\r
+\r
+ int last = virtualPath.Length - 1;\r
+ if (last == 0 || virtualPath [last] != '/')\r
+ return virtualPath;\r
+\r
+ return virtualPath.Substring (0, last);\r
+ }\r
+\r
+ public static string ToAbsolute (string virtualPath)\r
+ {\r
+ string apppath = HttpRuntime.AppDomainAppVirtualPath;\r
+ if (apppath == null)\r
+ throw new HttpException ("The path to the application is not known");\r
+\r
+ return ToAbsolute (virtualPath,apppath);\r
+ }\r
+\r
+ // If virtualPath is: \r
+ // Absolute, the ToAbsolute method returns the virtual path with no changes.\r
+ // Application relative, the ToAbsolute method adds applicationPath to the beginning of the virtual path.\r
+ // Not rooted, the ToAbsolute method raises an ArgumentOutOfRangeException exception.\r
+ public static string ToAbsolute (string virtualPath, string applicationPath)\r
+ {\r
+ if (applicationPath == null || applicationPath == "")\r
+ throw new ArgumentNullException ("applicationPath");\r
+\r
+ if (virtualPath == null || virtualPath == "")\r
+ throw new ArgumentNullException ("virtualPath");\r
+\r
+ if (virtualPath.Length > 1 && virtualPath [0] == '~' && virtualPath [1] == '/') {\r
+ if (applicationPath [0] != '/')\r
+ throw new ArgumentException ("appPath is not rooted", "applicationPath");\r
+ return UrlUtils.RemoveDoubleSlashes ((applicationPath + virtualPath.Substring (1)).Replace ('\\', '/'));\r
+ }\r
+\r
+ if (virtualPath [0] != '/')\r
+ throw new ArgumentException (String.Format ("Relative path not allowed: '{0}'", virtualPath));\r
+\r
+ return UrlUtils.RemoveDoubleSlashes (virtualPath.Replace ('\\', '/'));\r
+\r
+ }\r
+\r
+ public static string ToAppRelative (string virtualPath)\r
+ {\r
+ string apppath = HttpRuntime.AppDomainAppVirtualPath;\r
+ if (apppath == null)\r
+ throw new HttpException ("The path to the application is not known");\r
+\r
+ return ToAppRelative (apppath, virtualPath);\r
+ }\r
+\r
+ public static string ToAppRelative (string virtualPath, string applicationPath)\r
+ {\r
+ if (applicationPath == null || applicationPath == "")\r
+ throw new ArgumentNullException ("applicationPath");\r
+\r
+ if (virtualPath == null || virtualPath == "")\r
+ throw new ArgumentNullException ("virtualPath");\r
+\r
+ if (virtualPath.StartsWith (".."))\r
+ throw new ArgumentException (String.Format ("Relative path not allowed: '{0}'", virtualPath));\r
+\r
+ if (applicationPath [0] != '/')\r
+ throw new ArgumentOutOfRangeException ("appPath is not rooted", "applicationPath");\r
+\r
+ return MakeRelative (applicationPath, virtualPath);\r
+ }\r
+ }\r
+}\r
+\r
+#endif\r
+\r
-//
-// System.Web.VirtualPathUtilityTest.cs - Unit tests for System.Web.VirtualPathUtility
-//
-// Author:
-// Chris Toshok <toshok@novell.com>
-// Gonzalo Paniagua Javier (gonzalo@novell.com)
-//
-// Copyright (C) 2005,2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if NET_2_0
-
-using System;
-using System.Web;
-using VPU = System.Web.VirtualPathUtility;
-
-using NUnit.Framework;
-
-namespace MonoTests.System.Web {
-
- [TestFixture]
- public class VirtualPathUtilityTest {
- [Test]
- 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");
- }
-
- [Test]
- [Category ("NotWorking")]
- 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");
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentException))]
- public void Combine_ArgException1 ()
- {
- Assert.AreEqual ("hi/there/you", VPU.Combine ("hi/there", "you"), "A1");
- }
-
- [Test]
- [Category ("NotWorking")]
- [ExpectedException (typeof (ArgumentException))]
- public void Combine_ArgException2 ()
- {
- Assert.AreEqual ("hi/there", VPU.Combine ("hi/there", null), "A1");
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentNullException))]
- public void Combine_ArgException3 ()
- {
- Assert.AreEqual ("hi/there", VPU.Combine (null, "there"), "A1");
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentNullException))]
- /* stack trace is:
- at System.Web.VirtualPath.Create(String virtualPath, VirtualPathOptions options)
- at System.Web.VirtualPathUtility.Combine(String basePath, String relativePath)
- at MonoTests.System.Web.VirtualPathUtilityTest.Combine()
- */
- public void Combine_ArgException4 ()
- {
- Assert.AreEqual ("/you", VPU.Combine ("", "you"), "A1");
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentNullException))]
- /* stack trace is:
- at System.Web.VirtualPath.Create(String virtualPath, VirtualPathOptions options)
- at System.Web.VirtualPathUtility.Combine(String basePath, String relativePath)
- at MonoTests.System.Web.VirtualPathUtilityTest.Combine()
- */
- public void Combine_ArgException5 ()
- {
- Assert.AreEqual ("/hi", VPU.Combine ("/hi", ""), "A1");
- }
-
- [Test]
- [Category ("NotWorking")]
- public void GetDirectory ()
- {
- Assert.AreEqual ("/hi/", VPU.GetDirectory ("/hi/there"), "A1");
- Assert.AreEqual ("/hi/", VPU.GetDirectory ("/hi/there/"), "A2");
- Assert.AreEqual (null, VPU.GetDirectory ("/"), "A3");
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentNullException))]
- /* stack trace is:
- at System.Web.VirtualPath.Create(String virtualPath, VirtualPathOptions options)
- at System.Web.VirtualPathUtility.GetDirectory(String virtualPath)
- at MonoTests.System.Web.VirtualPathUtilityTest.GetDirectory()
- */
- public void GetDirectory_ArgException1 ()
- {
- Assert.AreEqual ("", VPU.GetDirectory (""), "A1");
- }
-
- [Test]
- [Category ("NotWorking")]
- public void GetExtension ()
- {
- Assert.AreEqual (".aspx", VPU.GetExtension ("/hi/index.aspx"), "A1");
- Assert.AreEqual (".aspx", VPU.GetExtension ("index.aspx"), "A2");
- Assert.AreEqual ("", VPU.GetExtension ("/hi/index"), "A3");
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentNullException))]
- public void GetExtension_ArgException1 ()
- {
- Assert.AreEqual (null, VPU.GetExtension (null), "A1");
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentNullException))]
- public void GetExtension_ArgException2 ()
- {
- Assert.AreEqual ("", VPU.GetExtension (""), "A1");
- }
-
- [Test]
- public void GetFileName ()
- {
- Assert.AreEqual ("index.aspx", VPU.GetFileName ("/hi/index.aspx"), "A1");
- Assert.AreEqual ("hi", VPU.GetFileName ("/hi/"), "A2");
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentNullException))]
- public void GetFileName_ArgException1 ()
- {
- Assert.AreEqual (null, VPU.GetFileName (null), "A1");
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentNullException))]
- public void GetFileName_ArgException2 ()
- {
- Assert.AreEqual ("", VPU.GetFileName (""), "A1");
- }
-
- [Test]
- [Category ("NotWorking")]
- [ExpectedException (typeof (ArgumentException))]
- public void GetFileName_ArgException3 ()
- {
- Assert.AreEqual ("index.aspx", VPU.GetFileName ("index.aspx"), "A1");
- }
-
- [Test]
- 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");
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentNullException))]
- public void IsAbsolute_ArgException1 ()
- {
- Assert.IsFalse (VPU.IsAbsolute (""), "A1");
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentNullException))]
- public void IsAbsolute_ArgException2 ()
- {
- Assert.IsFalse (VPU.IsAbsolute (null), "A1");
- }
-
- [Test]
- [Category ("NotWorking")]
- public void IsAppRelative ()
- {
- Assert.IsTrue (VPU.IsAppRelative ("~/Stuff"), "A1");
- Assert.IsFalse (VPU.IsAppRelative ("./Stuff"), "A2");
- Assert.IsFalse (VPU.IsAppRelative ("/Stuff"), "A3");
- Assert.IsFalse (VPU.IsAppRelative ("/"), "A4");
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentNullException))]
- public void IsAppRelative_ArgException1 ()
- {
- Assert.IsFalse (VPU.IsAppRelative (""), "A1");
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentNullException))]
- public void IsAppRelative_ArgException2 ()
- {
- Assert.IsFalse (VPU.IsAppRelative (null), "A1");
- }
-
-#if false
- [Test]
- /* this test when run on MS generates the following stack trace (NRE):
- at System.Web.Util.UrlPath.MakeVirtualPathAppAbsolute(String virtualPath, String applicationPath)
- at System.Web.Util.UrlPath.MakeRelative(String from, String to)
- at System.Web.VirtualPathUtility.MakeRelative(String fromPath, String toPath)
- at MonoTests.System.Web.VirtualPathUtilityTest.MakeRelative()
- */
- public void MakeRelative ()
- {
- Assert.AreEqual ("../bar", VPU.MakeRelative ("~/foo/hi", "~/foo/bar"), "A1");
- }
-#endif
-
- [Test]
- 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");
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentNullException))]
- public void Combine1 ()
- {
- VPU.Combine (null, "something");
- }
-
- [Test]
- [Category ("NotWorking")]
- [ExpectedException (typeof (ArgumentException))]
- public void Combine2 ()
- {
- VPU.Combine ("something", null);
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentNullException))]
- public void GetDirectory1 ()
- {
- VPU.GetDirectory (null);
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentNullException))]
- public void GetDirectory2 ()
- {
- VPU.GetDirectory ("");
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentException))]
- public void GetDirectory3 ()
- {
- VPU.GetDirectory ("hola");
- }
-
- [Test]
- 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"));
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentNullException))]
- public void GetExtension1 ()
- {
- VPU.GetExtension (null);
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentNullException))]
- public void GetExtension2 ()
- {
- // Amazing.
- VPU.GetExtension ("");
- }
-
- [Test]
- public void GetExtension3 ()
- {
- Assert.AreEqual ("", VPU.GetExtension ("/direc/somefilenoextension"));
- Assert.AreEqual ("", VPU.GetExtension ("/"));
- Assert.AreEqual ("/direc/", VPU.GetDirectory ("/////direc///somefile.aspx"));
- }
-
- [Test]
- public void GetFileName1 ()
- {
- Assert.AreEqual ("", VPU.GetFileName ("/"));
- Assert.AreEqual ("hola", VPU.GetFileName ("/hola"));
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentNullException))]
- public void GetFileName2 ()
- {
- VPU.GetFileName (null);
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentNullException))]
- public void GetFileName3 ()
- {
- VPU.GetFileName ("");
- }
-
- [Test]
- [ExpectedException (typeof (NullReferenceException))]
- public void MakeRelative1 ()
- {
- VPU.MakeRelative (null, "");
- }
-
- [Test]
- [ExpectedException (typeof (NullReferenceException))]
- public void MakeRelative2 ()
- {
- VPU.MakeRelative ("", null);
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentOutOfRangeException))]
- public void MakeRelative3 ()
- {
- VPU.MakeRelative ("/", "i");
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentOutOfRangeException))]
- public void MakeRelative4 ()
- {
- VPU.MakeRelative ("aa", "/i");
- }
-
- [Test]
- [Category ("NotWorking")]
- public void MakeRelative5 ()
- {
- Assert.AreEqual ("", VPU.MakeRelative ("", ""));
- Assert.AreEqual ("", VPU.MakeRelative ("/something", ""));
- Assert.AreEqual ("./", VPU.MakeRelative ("/", "/"));
- }
-
- [Test]
- 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/"));
- }
-
- [Test]
- [Category ("NotWorking")]
- [ExpectedException (typeof (ArgumentNullException))]
- public void ToAbsolute1 ()
- {
- VPU.ToAbsolute (null);
- }
-
- [Test]
- [Category ("NotWorking")]
- [ExpectedException (typeof (ArgumentNullException))]
- public void ToAbsolute2 ()
- {
- VPU.ToAbsolute ("");
- }
-
- [Test]
- [Category ("NotWorking")]
- [ExpectedException (typeof (ArgumentException))]
- public void ToAbsolute3 ()
- {
- VPU.ToAbsolute ("..");
- }
-
- [Test]
- [Category ("NotWorking")]
- [ExpectedException (typeof (ArgumentException))]
- public void ToAbsolute4 ()
- {
- VPU.ToAbsolute ("...");
- }
-
- [Test]
- [Category ("NotWorking")]
- [ExpectedException (typeof (ArgumentException))]
- public void ToAbsolute5 ()
- {
- VPU.ToAbsolute ("../blah");
- }
-
- [Test]
- [ExpectedException (typeof (HttpException))]
- public void ToAbsolute6 ()
- {
- VPU.ToAbsolute ("~/");
- }
-
- [Test]
- [ExpectedException (typeof (HttpException))]
- public void ToAbsolute7 ()
- {
- Assert.AreEqual ("/", VPU.ToAbsolute ("/"));
- }
-
- [Test]
- public void ToAbsolute8 ()
- {
- Assert.AreEqual ("/", VPU.ToAbsolute ("/", "/ROOT"));
- Assert.AreEqual ("/blah/blah/", VPU.ToAbsolute ("/blah//blah//", "/ROOT"));
- Assert.AreEqual ("/blah/blah/", VPU.ToAbsolute ("/blah\\blah/", "/ROOT"));
- }
-
- [Test]
- public void ToAbsolute9 ()
- {
- Assert.AreEqual ("/ROOT/", VPU.ToAbsolute ("~/", "/ROOT"));
- Assert.AreEqual ("/ROOT/blah", VPU.ToAbsolute ("~/blah", "/ROOT/"));
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentException))]
- public void ToAbsolute10 ()
- {
- VPU.ToAbsolute ("../blah", "/ROOT");
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentException))]
- public void ToAbsolute11 ()
- {
- VPU.ToAbsolute ("blah", "/ROOT");
- }
-
- [Test]
- [ExpectedException (typeof (ArgumentException))]
- public void ToAbsolute12 ()
- {
- VPU.ToAbsolute ("~/blah", "ROOT");
- }
-
- [Test]
- public void ToAbsolute13 ()
- {
- Assert.AreEqual ("/blah", VPU.ToAbsolute ("/blah", "ROOT"));
- }
- }
-}
-
-#endif
-
+//\r
+// System.Web.VirtualPathUtilityTest.cs - Unit tests for System.Web.VirtualPathUtility\r
+//\r
+// Author:\r
+// Chris Toshok <toshok@novell.com>\r
+// Gonzalo Paniagua Javier (gonzalo@novell.com)\r
+//\r
+// Copyright (C) 2005,2006 Novell, Inc (http://www.novell.com)\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+#if NET_2_0\r
+\r
+using System;\r
+using System.Web;\r
+using VPU = System.Web.VirtualPathUtility;\r
+\r
+using NUnit.Framework;\r
+\r
+namespace MonoTests.System.Web {\r
+\r
+ [TestFixture]\r
+ public class VirtualPathUtilityTest {\r
+ [Test]\r
+ public void AppendTrailingSlash ()\r
+ {\r
+ Assert.AreEqual ("/hithere/", VPU.AppendTrailingSlash ("/hithere"), "A1");\r
+ Assert.AreEqual ("/hithere/", VPU.AppendTrailingSlash ("/hithere/"), "A2");\r
+ Assert.AreEqual ("/", VPU.AppendTrailingSlash ("/"), "A3");\r
+ Assert.AreEqual ("", VPU.AppendTrailingSlash (""), "A4");\r
+ Assert.AreEqual (null, VPU.AppendTrailingSlash (null), "A5");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ public void Combine ()\r
+ {\r
+ Assert.AreEqual ("/there", VPU.Combine ("/hi", "there"), "A1");\r
+ Assert.AreEqual ("/hi/you", VPU.Combine ("/hi/there", "you"), "A2");\r
+ Assert.AreEqual ("/hi/there/you", VPU.Combine ("/hi/there/", "you"), "A3");\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentException))]\r
+ public void Combine_ArgException1 ()\r
+ {\r
+ Assert.AreEqual ("hi/there/you", VPU.Combine ("hi/there", "you"), "A1");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ [ExpectedException (typeof (ArgumentException))]\r
+ public void Combine_ArgException2 ()\r
+ {\r
+ Assert.AreEqual ("hi/there", VPU.Combine ("hi/there", null), "A1");\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentNullException))]\r
+ public void Combine_ArgException3 ()\r
+ {\r
+ Assert.AreEqual ("hi/there", VPU.Combine (null, "there"), "A1");\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentNullException))]\r
+ /* stack trace is:\r
+ at System.Web.VirtualPath.Create(String virtualPath, VirtualPathOptions options)\r
+ at System.Web.VirtualPathUtility.Combine(String basePath, String relativePath)\r
+ at MonoTests.System.Web.VirtualPathUtilityTest.Combine()\r
+ */\r
+ public void Combine_ArgException4 ()\r
+ {\r
+ Assert.AreEqual ("/you", VPU.Combine ("", "you"), "A1");\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentNullException))]\r
+ /* stack trace is:\r
+ at System.Web.VirtualPath.Create(String virtualPath, VirtualPathOptions options)\r
+ at System.Web.VirtualPathUtility.Combine(String basePath, String relativePath)\r
+ at MonoTests.System.Web.VirtualPathUtilityTest.Combine()\r
+ */\r
+ public void Combine_ArgException5 ()\r
+ {\r
+ Assert.AreEqual ("/hi", VPU.Combine ("/hi", ""), "A1");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ public void GetDirectory ()\r
+ {\r
+ Assert.AreEqual ("/hi/", VPU.GetDirectory ("/hi/there"), "A1");\r
+ Assert.AreEqual ("/hi/", VPU.GetDirectory ("/hi/there/"), "A2");\r
+ Assert.AreEqual (null, VPU.GetDirectory ("/"), "A3");\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentNullException))]\r
+ /* stack trace is:\r
+ at System.Web.VirtualPath.Create(String virtualPath, VirtualPathOptions options)\r
+ at System.Web.VirtualPathUtility.GetDirectory(String virtualPath)\r
+ at MonoTests.System.Web.VirtualPathUtilityTest.GetDirectory()\r
+ */\r
+ public void GetDirectory_ArgException1 ()\r
+ {\r
+ Assert.AreEqual ("", VPU.GetDirectory (""), "A1");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ public void GetExtension ()\r
+ {\r
+ Assert.AreEqual (".aspx", VPU.GetExtension ("/hi/index.aspx"), "A1");\r
+ Assert.AreEqual (".aspx", VPU.GetExtension ("index.aspx"), "A2");\r
+ Assert.AreEqual ("", VPU.GetExtension ("/hi/index"), "A3");\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentNullException))]\r
+ public void GetExtension_ArgException1 ()\r
+ {\r
+ Assert.AreEqual (null, VPU.GetExtension (null), "A1");\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentNullException))]\r
+ public void GetExtension_ArgException2 ()\r
+ {\r
+ Assert.AreEqual ("", VPU.GetExtension (""), "A1");\r
+ }\r
+\r
+ [Test]\r
+ public void GetFileName ()\r
+ {\r
+ Assert.AreEqual ("index.aspx", VPU.GetFileName ("/hi/index.aspx"), "A1");\r
+ Assert.AreEqual ("hi", VPU.GetFileName ("/hi/"), "A2");\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentNullException))]\r
+ public void GetFileName_ArgException1 ()\r
+ {\r
+ Assert.AreEqual (null, VPU.GetFileName (null), "A1");\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentNullException))]\r
+ public void GetFileName_ArgException2 ()\r
+ {\r
+ Assert.AreEqual ("", VPU.GetFileName (""), "A1");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ [ExpectedException (typeof (ArgumentException))]\r
+ public void GetFileName_ArgException3 ()\r
+ {\r
+ Assert.AreEqual ("index.aspx", VPU.GetFileName ("index.aspx"), "A1");\r
+ }\r
+\r
+ [Test]\r
+ public void IsAbsolute ()\r
+ {\r
+ Assert.IsTrue (VPU.IsAbsolute ("/"), "A1");\r
+ Assert.IsTrue (VPU.IsAbsolute ("/hi/there"), "A2");\r
+ Assert.IsFalse (VPU.IsAbsolute ("hi/there"), "A3");\r
+ Assert.IsFalse (VPU.IsAbsolute ("./hi"), "A4");\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentNullException))]\r
+ public void IsAbsolute_ArgException1 ()\r
+ {\r
+ Assert.IsFalse (VPU.IsAbsolute (""), "A1");\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentNullException))]\r
+ public void IsAbsolute_ArgException2 ()\r
+ {\r
+ Assert.IsFalse (VPU.IsAbsolute (null), "A1");\r
+ }\r
+\r
+ [Test]\r
+ public void IsAppRelative ()\r
+ {\r
+ Assert.IsTrue (VPU.IsAppRelative ("~"), "A0");\r
+ Assert.IsTrue (VPU.IsAppRelative ("~/Stuff"), "A1");\r
+ Assert.IsFalse (VPU.IsAppRelative ("./Stuff"), "A2");\r
+ Assert.IsFalse (VPU.IsAppRelative ("/Stuff"), "A3");\r
+ Assert.IsFalse (VPU.IsAppRelative ("/"), "A4");\r
+ Assert.IsFalse (VPU.IsAppRelative ("~Stuff"), "A5");\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentNullException))]\r
+ public void IsAppRelative_ArgException1 ()\r
+ {\r
+ Assert.IsFalse (VPU.IsAppRelative (""), "A1");\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentNullException))]\r
+ public void IsAppRelative_ArgException2 ()\r
+ {\r
+ Assert.IsFalse (VPU.IsAppRelative (null), "A1");\r
+ }\r
+\r
+#if false\r
+ [Test]\r
+ /* this test when run on MS generates the following stack trace (NRE):\r
+ at System.Web.Util.UrlPath.MakeVirtualPathAppAbsolute(String virtualPath, String applicationPath)\r
+ at System.Web.Util.UrlPath.MakeRelative(String from, String to)\r
+ at System.Web.VirtualPathUtility.MakeRelative(String fromPath, String toPath)\r
+ at MonoTests.System.Web.VirtualPathUtilityTest.MakeRelative()\r
+ */\r
+ public void MakeRelative ()\r
+ {\r
+ Assert.AreEqual ("../bar", VPU.MakeRelative ("~/foo/hi", "~/foo/bar"), "A1");\r
+ }\r
+#endif\r
+\r
+ [Test]\r
+ public void RemoveTrailingSlash ()\r
+ {\r
+ Assert.AreEqual ("/hi/there", VPU.RemoveTrailingSlash ("/hi/there/"), "A1");\r
+ Assert.AreEqual ("/hi/there", VPU.RemoveTrailingSlash ("/hi/there"), "A2");\r
+ Assert.AreEqual ("/", VPU.RemoveTrailingSlash ("/"), "A3");\r
+ Assert.AreEqual (null, VPU.RemoveTrailingSlash (""), "A4");\r
+ Assert.AreEqual (null, VPU.RemoveTrailingSlash (null), "A5");\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentNullException))]\r
+ public void Combine1 ()\r
+ {\r
+ VPU.Combine (null, "something");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ [ExpectedException (typeof (ArgumentException))]\r
+ public void Combine2 ()\r
+ {\r
+ VPU.Combine ("something", null);\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentNullException))]\r
+ public void GetDirectory1 ()\r
+ {\r
+ VPU.GetDirectory (null);\r
+ }\r
+ \r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentNullException))]\r
+ public void GetDirectory2 ()\r
+ {\r
+ VPU.GetDirectory ("");\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentException))]\r
+ public void GetDirectory3 ()\r
+ {\r
+ VPU.GetDirectory ("hola");\r
+ }\r
+\r
+ [Test]\r
+ public void GetDirectory4 ()\r
+ {\r
+ Assert.AreEqual ("/direc/", VPU.GetDirectory ("/direc/somefilenoextension"));\r
+ Assert.AreEqual ("/direc/", VPU.GetDirectory ("/direc/somefile.aspx"));\r
+ Assert.AreEqual ("/direc/", VPU.GetDirectory ("/////direc///somefile.aspx"));\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentNullException))]\r
+ public void GetExtension1 ()\r
+ {\r
+ VPU.GetExtension (null);\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentNullException))]\r
+ public void GetExtension2 ()\r
+ {\r
+ // Amazing.\r
+ VPU.GetExtension ("");\r
+ }\r
+\r
+ [Test]\r
+ public void GetExtension3 ()\r
+ {\r
+ Assert.AreEqual ("", VPU.GetExtension ("/direc/somefilenoextension"));\r
+ Assert.AreEqual ("", VPU.GetExtension ("/"));\r
+ Assert.AreEqual ("/direc/", VPU.GetDirectory ("/////direc///somefile.aspx"));\r
+ }\r
+\r
+ [Test]\r
+ public void GetFileName1 ()\r
+ {\r
+ Assert.AreEqual ("", VPU.GetFileName ("/"));\r
+ Assert.AreEqual ("hola", VPU.GetFileName ("/hola"));\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentNullException))]\r
+ public void GetFileName2 ()\r
+ {\r
+ VPU.GetFileName (null);\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentNullException))]\r
+ public void GetFileName3 ()\r
+ {\r
+ VPU.GetFileName ("");\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (NullReferenceException))]\r
+ public void MakeRelative1 ()\r
+ {\r
+ VPU.MakeRelative (null, "");\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (NullReferenceException))]\r
+ public void MakeRelative2 ()\r
+ {\r
+ VPU.MakeRelative ("", null);\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]\r
+ public void MakeRelative3 ()\r
+ {\r
+ VPU.MakeRelative ("/", "i");\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]\r
+ public void MakeRelative4 ()\r
+ {\r
+ VPU.MakeRelative ("aa", "/i");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ public void MakeRelative5 ()\r
+ {\r
+ Assert.AreEqual ("", VPU.MakeRelative ("", ""));\r
+ Assert.AreEqual ("", VPU.MakeRelative ("/something", ""));\r
+ Assert.AreEqual ("./", VPU.MakeRelative ("/", "/"));\r
+ }\r
+\r
+ [Test]\r
+ public void RemoveTrailingSlash2 ()\r
+ {\r
+ Assert.AreEqual (null, VPU.RemoveTrailingSlash (null));\r
+ Assert.AreEqual (null, VPU.RemoveTrailingSlash (""));\r
+ Assert.AreEqual ("/", VPU.RemoveTrailingSlash ("/"));\r
+ Assert.AreEqual ("////", VPU.RemoveTrailingSlash ("/////"));\r
+ Assert.AreEqual ("/pepe", VPU.RemoveTrailingSlash ("/pepe"));\r
+ Assert.AreEqual ("/pepe", VPU.RemoveTrailingSlash ("/pepe/"));\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ [ExpectedException (typeof (ArgumentNullException))]\r
+ public void ToAbsolute1 ()\r
+ {\r
+ VPU.ToAbsolute (null);\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ [ExpectedException (typeof (ArgumentNullException))]\r
+ public void ToAbsolute2 ()\r
+ {\r
+ VPU.ToAbsolute ("");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ [ExpectedException (typeof (ArgumentException))]\r
+ public void ToAbsolute3 ()\r
+ {\r
+ VPU.ToAbsolute ("..");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ [ExpectedException (typeof (ArgumentException))]\r
+ public void ToAbsolute4 ()\r
+ {\r
+ VPU.ToAbsolute ("...");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ [ExpectedException (typeof (ArgumentException))]\r
+ public void ToAbsolute5 ()\r
+ {\r
+ VPU.ToAbsolute ("../blah");\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (HttpException))]\r
+ public void ToAbsolute6 ()\r
+ {\r
+ VPU.ToAbsolute ("~/");\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (HttpException))]\r
+ public void ToAbsolute7 ()\r
+ {\r
+ Assert.AreEqual ("/", VPU.ToAbsolute ("/"));\r
+ }\r
+\r
+ [Test]\r
+ public void ToAbsolute8 ()\r
+ {\r
+ Assert.AreEqual ("/", VPU.ToAbsolute ("/", "/ROOT"));\r
+ Assert.AreEqual ("/blah/blah/", VPU.ToAbsolute ("/blah//blah//", "/ROOT"));\r
+ Assert.AreEqual ("/blah/blah/", VPU.ToAbsolute ("/blah\\blah/", "/ROOT"));\r
+ }\r
+\r
+ [Test]\r
+ public void ToAbsolute9 ()\r
+ {\r
+ Assert.AreEqual ("/ROOT/", VPU.ToAbsolute ("~/", "/ROOT"));\r
+ Assert.AreEqual ("/ROOT/blah", VPU.ToAbsolute ("~/blah", "/ROOT/"));\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentException))]\r
+ public void ToAbsolute10 ()\r
+ {\r
+ VPU.ToAbsolute ("../blah", "/ROOT");\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentException))]\r
+ public void ToAbsolute11 ()\r
+ {\r
+ VPU.ToAbsolute ("blah", "/ROOT");\r
+ }\r
+\r
+ [Test]\r
+ [ExpectedException (typeof (ArgumentException))]\r
+ public void ToAbsolute12 ()\r
+ {\r
+ VPU.ToAbsolute ("~/blah", "ROOT");\r
+ }\r
+\r
+ [Test]\r
+ public void ToAbsolute13 ()\r
+ {\r
+ Assert.AreEqual ("/blah", VPU.ToAbsolute ("/blah", "ROOT"));\r
+ }\r
+ }\r
+}\r
+\r
+#endif\r
+\r