本文整理汇总了C#中MonoTests.System.Web.Routing.HttpContextStub类的典型用法代码示例。如果您正苦于以下问题:C# HttpContextStub类的具体用法?C# HttpContextStub怎么用?C# HttpContextStub使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpContextStub类属于MonoTests.System.Web.Routing命名空间,在下文中一共展示了HttpContextStub类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRouteData16
public void GetRouteData16 ()
{
var r = new Route ("My{location}---{sublocation}", null);
var hc = new HttpContextStub ("~/MyHouse-LivingRoom", String.Empty);
var rd = r.GetRouteData (hc);
Assert.IsNull (rd, "#1");
}
示例2: GetRouteData43
public void GetRouteData43 ()
{
// {} matches and substitutes even at partial state ...
var r = new Route ("{foo}-{bar}-{baz}", null);
var hc = new HttpContextStub ("~/--", String.Empty);
var rd = r.GetRouteData (hc);
Assert.IsNull (rd, "#1");
hc = new HttpContextStub ("~/1-2-3", String.Empty);
rd = r.GetRouteData (hc);
Assert.IsNotNull (rd, "#2");
Assert.AreEqual (r, rd.Route, "#2");
Assert.AreEqual (0, rd.DataTokens.Count, "#3");
Assert.AreEqual (3, rd.Values.Count, "#4");
Assert.AreEqual ("1", rd.Values ["foo"], "#4-1");
Assert.AreEqual ("2", rd.Values ["bar"], "#4-2");
Assert.AreEqual ("3", rd.Values ["baz"], "#4-2");
}
示例3: GetRouteData28
public void GetRouteData28 ()
{
var r = new Route ("{foo}xyz{bar}xyz{baz}", null);
var hc = new HttpContextStub ("~/xyzxyzxyzxyzblah", String.Empty);
var rd = r.GetRouteData (hc);
Assert.IsNull (rd, "#1");
}
示例4: GetRouteData33
public void GetRouteData33 ()
{
var r = new Route (null, null);
var hc = new HttpContextStub ("~/", String.Empty);
var rd = r.GetRouteData (hc);
Assert.IsNotNull (rd, "#1");
Assert.AreEqual (r, rd.Route, "#2");
Assert.AreEqual (0, rd.DataTokens.Count, "#3");
Assert.AreEqual (0, rd.Values.Count, "#4");
}
示例5: GetRouteData37
public void GetRouteData37 ()
{
var r = new Route ("{foo}xyz{bar}xyz{baz}", null);
var hc = new HttpContextStub ("~/xyzxyzxyzxyzxyz", String.Empty);
var rd = r.GetRouteData (hc);
#if NET_4_0 || !DOTNET
// When running on Mono this test succeeds - it was a bug in .NET routing for 3.5 which
// we don't reproduce anymore.
Assert.IsNotNull (rd, "#1");
Assert.AreEqual (r, rd.Route, "#2");
Assert.AreEqual (0, rd.DataTokens.Count, "#3");
Assert.AreEqual (3, rd.Values.Count, "#4");
Assert.AreEqual ("xyz", rd.Values ["foo"], "#4-1");
Assert.AreEqual ("xyz", rd.Values ["bar"], "#4-2");
Assert.AreEqual ("xyz", rd.Values ["baz"], "#4-3");
#else
Assert.IsNull (rd, "#1");
#endif
}
示例6: GetRouteData26
public void GetRouteData26 ()
{
var r = new Route ("foo/{bar}/{baz}-{dancefloor}", null) {
Defaults = new RouteValueDictionary (new { baz = "nyc", dancefloor = 1 })
};
var hc = new HttpContextStub ("~/foo/BlueOyster", String.Empty);
var rd = r.GetRouteData (hc);
Assert.IsNull (rd, "#1");
hc = new HttpContextStub ("~/foo/blueoyster/bigapple", String.Empty);
rd = r.GetRouteData (hc);
Assert.IsNull (rd, "#2");
hc = new HttpContextStub ("~/foo/blueoyster/bigapple-3", String.Empty);
rd = r.GetRouteData (hc);
Assert.IsNotNull (rd, "#3");
Assert.AreEqual (r, rd.Route, "#3-1");
Assert.AreEqual (0, rd.DataTokens.Count, "#3-2");
Assert.AreEqual (3, rd.Values.Count, "#3-3");
Assert.AreEqual ("blueoyster", rd.Values["bar"], "#3-4");
Assert.AreEqual ("bigapple", rd.Values["baz"], "#3-5");
Assert.AreEqual ("3", rd.Values["dancefloor"], "#3-6");
Assert.IsTrue (typeof (string) == rd.Values["dancefloor"].GetType (), "#3-7");
hc = new HttpContextStub ("~/foo/blueoyster/-", String.Empty);
rd = r.GetRouteData (hc);
Assert.IsNull (rd, "#4");
}
示例7: GetRouteData30
public void GetRouteData30 ()
{
var r = new Route ("{foo}/bar/{baz}/boo/{blah}", null) {
Defaults = new RouteValueDictionary (new { baz = "meep", blah = "blurb" })
};
var hc = new HttpContextStub ("~/foo/bar", String.Empty);
var rd = r.GetRouteData (hc);
Assert.IsNull (rd, "#1");
hc = new HttpContextStub ("~/foo/bar/baz/boo", String.Empty);
rd = r.GetRouteData (hc);
Assert.IsNotNull (rd, "#2");
Assert.AreEqual (r, rd.Route, "#3");
Assert.AreEqual (0, rd.DataTokens.Count, "#4");
Assert.AreEqual (3, rd.Values.Count, "#4");
Assert.AreEqual ("foo", rd.Values["foo"], "#4-1");
Assert.AreEqual ("baz", rd.Values["baz"], "#4-2");
Assert.AreEqual ("blurb", rd.Values["blah"], "#4-3");
}
示例8: InvalidConstraint
public void InvalidConstraint ()
{
var r = new Route ("{foo}/{bar}", new StopRoutingHandler ());
var c = new RouteValueDictionary ();
c ["foo"] = Guid.NewGuid ();
r.Constraints = c;
var hc = new HttpContextStub ("~/x/y", String.Empty);
var rd = r.GetRouteData (hc);
}
示例9: GetRouteData
public void GetRouteData ()
{
var r = new Route ("{foo}/{bar}", null);
var hc = new HttpContextStub ("~/x/y", String.Empty);
var rd = r.GetRouteData (hc);
Assert.IsNotNull (rd, "#1");
Assert.AreEqual (r, rd.Route, "#2");
Assert.AreEqual (0, rd.DataTokens.Count, "#3");
Assert.AreEqual (2, rd.Values.Count, "#4");
Assert.AreEqual ("x", rd.Values ["foo"], "#4-1");
Assert.AreEqual ("y", rd.Values ["bar"], "#4-2");
}
示例10: GetRouteDataWithCatchAll
public void GetRouteDataWithCatchAll ()
{
var r = new Route ("{*path}", new StopRoutingHandler ()) {
Defaults = new RouteValueDictionary (new {
controller = "Error",
action = "NotFound"
})
};
var hc = new HttpContextStub ("~/", String.Empty);
var rd = r.GetRouteData (hc);
Assert.IsNotNull (rd, "#1");
hc = new HttpContextStub ("~/Foo/x123", String.Empty);
rd = r.GetRouteData (hc);
Assert.IsNotNull (rd, "#2");
}
示例11: GetVirtualPath10
public void GetVirtualPath10 ()
{
var r = new MyRoute ("{foo}/{bar}", new MyRouteHandler ());
var hc = new HttpContextStub ("~/foo/bar", String.Empty);
var rd = r.GetRouteData (hc);
Assert.IsNotNull (rd, "#1");
var vp = r.GetVirtualPath (new RequestContext (hc, rd), new RouteValueDictionary (new { page = 3 }));
Assert.IsNotNull (vp, "#2");
Assert.AreEqual ("foo/bar?page=3", vp.VirtualPath, "#2-1");
vp = r.GetVirtualPath (new RequestContext (hc, rd), new RouteValueDictionary (new { page = 3, another = "stuff" }));
Assert.IsNotNull (vp, "#3");
Assert.AreEqual ("foo/bar?page=3&another=stuff", vp.VirtualPath, "#3-1");
vp = r.GetVirtualPath (new RequestContext (hc, rd), new RouteValueDictionary (new { page = 3, another = "stuff", value = "with ; spaces & other chars" }));
Assert.IsNotNull (vp, "#4");
Assert.AreEqual ("foo/bar?page=3&another=stuff&value=with%20%3B%20spaces%20%26%20other%20chars", vp.VirtualPath, "#4-1");
}
示例12: GetRouteData47
public void GetRouteData47 ()
{
var r = new Route ("Foo/{id}", new StopRoutingHandler ()) {
Defaults = new RouteValueDictionary (new {
controller = "Foo",
action = "Retrieve"
}),
Constraints = new RouteValueDictionary (new {
id = @"\d{1,10}"
})
};
var hc = new HttpContextStub ("~/Foo/x123", String.Empty);
var rd = r.GetRouteData (hc);
Assert.IsNull (rd, "#1");
}
示例13: GetRouteData46
public void GetRouteData46 ()
{
var r = new Route ("Foo", null) {
Defaults = new RouteValueDictionary (new {
controller = "Foo",
action = "Index"
})
};
var hc = new HttpContextStub ("/Foo/123", String.Empty);
var rd = r.GetRouteData (hc);
Assert.IsNull (rd, "#1");
r = new Route ("Foo", null) {
Defaults = new RouteValueDictionary (new {
controller = "Foo",
action = "Index"
})
};
hc = new HttpContextStub ("~/Foo/123", String.Empty);
rd = r.GetRouteData (hc);
Assert.IsNull (rd, "#2");
}
示例14: GetRouteDataWithCatchAll2
public void GetRouteDataWithCatchAll2 ()
{
var r = new Route ("something/{*path}", new StopRoutingHandler ()) {
Defaults = new RouteValueDictionary (new {
controller = "Error",
action = "NotFound"
})
};
var hc = new HttpContextStub ("~/", String.Empty);
var rd = r.GetRouteData (hc);
Assert.IsNull (rd, "#1");
hc = new HttpContextStub ("~/something", String.Empty);
rd = r.GetRouteData (hc);
Assert.IsNotNull (rd, "#2");
Assert.IsNull (rd.Values["path"], "#2.1");
hc = new HttpContextStub ("~/something/", String.Empty);
rd = r.GetRouteData (hc);
Assert.IsNotNull (rd, "#3");
Assert.IsNull (rd.Values["path"], "#3.1");
hc = new HttpContextStub ("~/something/algo", String.Empty);
rd = r.GetRouteData (hc);
Assert.IsNotNull (rd, "#4");
Assert.AreEqual ("algo", rd.Values["path"], "#4.1");
}
示例15: GetRouteData22
public void GetRouteData22 ()
{
var r = new Route ("foo/{ \t\n}", null);
var hc = new HttpContextStub ("~/FOO/stuff", String.Empty);
var rd = r.GetRouteData (hc);
Assert.IsNotNull (rd, "#1");
Assert.AreEqual (r, rd.Route, "#2");
Assert.AreEqual (0, rd.DataTokens.Count, "#3");
Assert.AreEqual (1, rd.Values.Count, "#4");
Assert.AreEqual ("stuff", rd.Values[" \t\n"], "#4-1");
}