本文整理汇总了C#中MonoTests.System.Web.Routing.HttpContextStub类的典型用法代码示例。如果您正苦于以下问题:C# HttpContextStub类的具体用法?C# HttpContextStub怎么用?C# HttpContextStub使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpContextStub类属于MonoTests.System.Web.Routing命名空间,在下文中一共展示了HttpContextStub类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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");
}
开发者ID:stabbylambda,项目名称:mono,代码行数:8,代码来源:RouteTest.cs
示例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");
}
开发者ID:stabbylambda,项目名称:mono,代码行数:18,代码来源:RouteTest.cs
示例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");
}
开发者ID:runefs,项目名称:Marvin,代码行数:8,代码来源:RouteTest.cs
示例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");
}
开发者ID:stabbylambda,项目名称:mono,代码行数:11,代码来源:RouteTest.cs
示例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
}
开发者ID:stabbylambda,项目名称:mono,代码行数:20,代码来源:RouteTest.cs
示例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");
}
开发者ID:stabbylambda,项目名称:mono,代码行数:31,代码来源:RouteTest.cs
示例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");
}
开发者ID:stabbylambda,项目名称:mono,代码行数:22,代码来源:RouteTest.cs
示例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);
}
开发者ID:stabbylambda,项目名称:mono,代码行数:9,代码来源:RouteTest.cs
示例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");
}
开发者ID:stabbylambda,项目名称:mono,代码行数:12,代码来源:RouteTest.cs
示例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");
}
开发者ID:rabink,项目名称:mono,代码行数:19,代码来源:RouteTest.cs
示例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");
}
开发者ID:stabbylambda,项目名称:mono,代码行数:20,代码来源:RouteTest.cs
示例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");
}
开发者ID:rabink,项目名称:mono,代码行数:17,代码来源:RouteTest.cs
示例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");
}
开发者ID:rabink,项目名称:mono,代码行数:22,代码来源:RouteTest.cs
示例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");
}
开发者ID:rabink,项目名称:mono,代码行数:33,代码来源:RouteTest.cs
示例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");
}
开发者ID:stabbylambda,项目名称:mono,代码行数:12,代码来源:RouteTest.cs
示例16: GetRouteData4
public void GetRouteData4 ()
{
var r = new Route ("{foo}/{bar}", null);
var hc = new HttpContextStub ("~/x", String.Empty);
var rd = r.GetRouteData (hc);
Assert.IsNull (rd); // mismatch
}
开发者ID:stabbylambda,项目名称:mono,代码行数:7,代码来源:RouteTest.cs
示例17: GetRouteData23
public void GetRouteData23 ()
{
var r = new Route ("foo/{bar}-{baz}/{dancefloor}", null) {
Defaults = new RouteValueDictionary (new { bar = "BlueOyster", dancefloor = 1 })
};
var hc = new HttpContextStub ("~/foo/-nyc/1", String.Empty);
var rd = r.GetRouteData (hc);
Assert.IsNull (rd, "#1");
hc = new HttpContextStub ("~/foo/blueoyster-nyc", String.Empty);
rd = r.GetRouteData (hc);
Assert.IsNotNull (rd, "#2");
Assert.AreEqual (r, rd.Route, "#2-1");
Assert.AreEqual (0, rd.DataTokens.Count, "#2-2");
Assert.AreEqual (3, rd.Values.Count, "#2-3");
Assert.AreEqual ("blueoyster", rd.Values["bar"], "#2-4");
Assert.AreEqual ("nyc", rd.Values["baz"], "#2-5");
Assert.AreEqual (1, rd.Values["dancefloor"], "#2-6");
Assert.IsTrue (typeof (int) == rd.Values["dancefloor"].GetType (), "#2-7");
}
开发者ID:stabbylambda,项目名称:mono,代码行数:21,代码来源:RouteTest.cs
示例18: GetRouteData8
public void GetRouteData8 ()
{
var r = new Route ("{first}/{*rest}", null);
var hc = new HttpContextStub ("~/a/b/c/d", 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 ("a", rd.Values ["first"], "#4-1");
Assert.AreEqual ("b/c/d", rd.Values ["rest"], "#4-2");
}
开发者ID:stabbylambda,项目名称:mono,代码行数:12,代码来源:RouteTest.cs
示例19: GetRouteData27
public void GetRouteData27 ()
{
var r = new Route ("foo/{bar}/{baz}/{dancefloor}", null) {
Defaults = new RouteValueDictionary (new { bar = "BlueOyster", dancefloor = 1 })
};
var hc = new HttpContextStub ("~/foo/nyc", String.Empty);
var rd = r.GetRouteData (hc);
Assert.IsNull (rd, "#1");
}
开发者ID:stabbylambda,项目名称:mono,代码行数:10,代码来源:RouteTest.cs
示例20: GetRouteData12
public void GetRouteData12 ()
{
var r = new Route ("summary/{action}-{type}/{page}", null);
var hc = new HttpContextStub ("~/summary/test-xml", String.Empty);
var rd = r.GetRouteData (hc);
Assert.IsNull (rd, "#1"); // mismatch, missing page
}
开发者ID:stabbylambda,项目名称:mono,代码行数:8,代码来源:RouteTest.cs
注:本文中的MonoTests.System.Web.Routing.HttpContextStub类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论