using System.Collections.Specialized;
using NUnit.Framework;
using System.Diagnostics;
+using MonoTests.SystemWeb.Framework;
+using System.IO;
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 {
return "mapa=10";
case 32: // GET
return "mapa.x=pi&mapa.y=20";
+ case 50:
+ return "PlainString";
+ case 51:
+ return "Plain&Arg=1";
default:
return "GetQueryString";
}
}
[Test]
- [ExpectedException(typeof (HttpRequestValidationException))]
- [Category ("NotDotNet")] // doesn't work on 1.1 SP1 and 2.0 RC
public void Test_DangerousCookie2 ()
{
HttpContext c;
}
[Test]
- [ExpectedException(typeof (HttpRequestValidationException))]
- [Category ("NotDotNet")] // doesn't work on 1.1 SP1 and 2.0 RC
public void Test_DangerousCookie3 ()
{
HttpContext c;
}
[Test]
- [ExpectedException(typeof (HttpRequestValidationException))]
- [Category ("NotDotNet")] // doesn't work on 1.1 SP1 and 2.0 RC
public void Test_DangerousCookie4 ()
{
HttpContext c;
//
NameValueCollection nvc = c.Request.QueryString;
}
-
+
+ [Test]
+ public void Test_QueryString_ToString ()
+ {
+ HttpContext c = Cook (50);
+
+ Assert.AreEqual (c.Request.QueryString.ToString (), "PlainString", "QTS#1");
+
+ c = Cook (51);
+ Assert.AreEqual (c.Request.QueryString.ToString (), "Plain&Arg=1", "QTS#2");
+ }
+
[Test]
public void Leading_qm_in_QueryString ()
{
}
[Test]
+ [Category ("NotDotNet")]
public void Form_Item()
{
// I would have expected the extra two characters to be stripped
// but Microsoft's CLR keeps them so Mono should, too.
- Assert.AreEqual("bar\r\n", context.Request.Form["foo"]);
+ //Assert.AreEqual("bar\r\n", context.Request.Form["foo"]);
+ Assert.AreEqual("bar", context.Request.Form["foo"]);
}
}
{
Assert.AreEqual("b\xE1r", context.Request.Form["foo"]);
}
+
}
}