X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem.Web%2FTest%2FSystem.Web%2FHttpRequestTest.cs;h=ffad4250d74f924216078f6bdf264824f5de9f00;hb=6110fc90713ce59ff0996fcd3520e09a96575820;hp=23c055c7deb147f85fd686b701685622dd29a5e9;hpb=f73e0d5c67f0d26e85b92fc4b75fc48783f20d64;p=mono.git diff --git a/mcs/class/System.Web/Test/System.Web/HttpRequestTest.cs b/mcs/class/System.Web/Test/System.Web/HttpRequestTest.cs index 23c055c7deb..ffad4250d74 100644 --- a/mcs/class/System.Web/Test/System.Web/HttpRequestTest.cs +++ b/mcs/class/System.Web/Test/System.Web/HttpRequestTest.cs @@ -33,6 +33,8 @@ using System.Web; using System.Collections.Specialized; using NUnit.Framework; using System.Diagnostics; +using MonoTests.SystemWeb.Framework; +using System.IO; namespace MonoTests.System.Web { @@ -129,7 +131,66 @@ namespace MonoTests.System.Web { HttpRequest r = new HttpRequest ("file", url, qs); string s = r.PhysicalApplicationPath; } + + [Test] + public void Test_QueryStringDecoding() + { + string url = "http://www.gnome.org/"; + string qs = "umlaut=" + HttpUtility.UrlEncode("\u00e4", Encoding.Default); + + HttpRequest r = new HttpRequest ("file", url, qs); + Assert.AreEqual("\u00e4", r.QueryString["umlaut"]); + } + + [Test] + [Category ("NunitWeb")] + public void Test_PhysicalApplicationPath () + { + WebTest t = new WebTest (new HandlerInvoker (new HandlerDelegate ( + PhysicalApplicationPathDelegate))); + t.Run (); + } + + static public void PhysicalApplicationPathDelegate () + { + HttpRequest r = HttpContext.Current.Request; + string pap = r.PhysicalApplicationPath; + Assert.IsTrue (pap.EndsWith (Path.DirectorySeparatorChar.ToString()), "#1"); + Assert.AreEqual (Path.GetFullPath (pap), pap, "#2"); + } + + [Test] + [Category ("NunitWeb")] + public void Test_MapPath () + { + WebTest t = new WebTest (new HandlerInvoker (new HandlerDelegate ( + MapPathDelegate))); + t.Run (); + } + + static public void MapPathDelegate () + { + HttpRequest r = HttpContext.Current.Request; + string appBase = r.PhysicalApplicationPath.TrimEnd (Path.DirectorySeparatorChar); + Assert.AreEqual (appBase, r.MapPath ("~"), "test1"); + Assert.AreEqual (appBase, r.MapPath ("/NunitWeb"), "test1.1"); + Assert.AreEqual (Path.Combine (appBase, "Web.config"), + r.MapPath ("Web.config"), "test2"); + Assert.AreEqual (Path.Combine (appBase, "Web.config"), + r.MapPath ("~/Web.config"), "test3"); + Assert.AreEqual (Path.Combine (appBase, "Web.config"), + r.MapPath ("/NunitWeb/Web.config"), "test4"); + Assert.AreEqual (Path.Combine (appBase, "Web.config"), + r.MapPath ("Web.config", null, false), "test5"); + Assert.AreEqual (Path.Combine (appBase, "Web.config"), + r.MapPath ("Web.config", "", false), "test6"); + Assert.AreEqual (Path.Combine (appBase, "Web.config"), + r.MapPath ("Web.config", "/NunitWeb", false), "test7"); + Assert.AreEqual (Path.Combine (appBase, "Web.config"), + r.MapPath ("/NunitWeb/Web.config", "/NunitWeb", false), "test8"); + } } + [TestFixture] public class Test_HttpFakeRequest { @@ -487,8 +548,6 @@ namespace MonoTests.System.Web { } [Test] - [ExpectedException(typeof (HttpRequestValidationException))] - [Category ("NotDotNet")] // doesn't work on 1.1 SP1 and 2.0 RC public void Test_DangerousCookie2 () { HttpContext c; @@ -499,8 +558,6 @@ namespace MonoTests.System.Web { } [Test] - [ExpectedException(typeof (HttpRequestValidationException))] - [Category ("NotDotNet")] // doesn't work on 1.1 SP1 and 2.0 RC public void Test_DangerousCookie3 () { HttpContext c; @@ -511,8 +568,6 @@ namespace MonoTests.System.Web { } [Test] - [ExpectedException(typeof (HttpRequestValidationException))] - [Category ("NotDotNet")] // doesn't work on 1.1 SP1 and 2.0 RC public void Test_DangerousCookie4 () { HttpContext c; @@ -879,6 +934,7 @@ namespace MonoTests.System.Web { { Assert.AreEqual("b\xE1r", context.Request.Form["foo"]); } + } }