本文整理汇总了C#中RouteHandler.Find方法的典型用法代码示例。如果您正苦于以下问题:C# RouteHandler.Find方法的具体用法?C# RouteHandler.Find怎么用?C# RouteHandler.Find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RouteHandler
的用法示例。
在下文中一共展示了RouteHandler.Find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestChangePatterns
public void TestChangePatterns()
{
//
// Ensure that changing the patterns property works.
// This is a bit of an edge case because internally
// the patterns strings are cached as an array of
// regexes.
//
var target = new MockManosTarget ();
var rh = new RouteHandler ("^foo", "GET", target);
var request = new MockHttpRequest ("GET", "foo");
Assert.AreEqual (target, rh.Find (request), "sanity-1");
rh.Patterns [0] = "baz";
Assert.IsNull (rh.Find (request), "sanity-2");
request = new MockHttpRequest ("GET", "baz");
Assert.AreEqual (target, rh.Find (request), "changed");
}
示例2: Find_PartialMatchAtBeginningOfChildlessHandler_ReturnsProperRoute
public void Find_PartialMatchAtBeginningOfChildlessHandler_ReturnsProperRoute()
{
var rh_bad = new RouteHandler ("foo", "GET", new ActionTarget (FakeAction));
var rh_good = new RouteHandler ("foobar", "GET", new ActionTarget (FakeAction2));
var rh = new RouteHandler ();
rh.Children.Add (rh_bad);
rh.Children.Add (rh_good);
var request = new MockHttpRequest ("GET", "foobar");
var res = rh.Find (request);
Assert.AreEqual (rh_good.Target, res);
}
示例3: Find_PartialMatchAtBeginningOfHandlerWithChildren_ReturnsProperRoute
public void Find_PartialMatchAtBeginningOfHandlerWithChildren_ReturnsProperRoute()
{
var rh_bad = new RouteHandler ("foo", HttpMethod.HTTP_GET);
var rh_good = new RouteHandler ("foobar", HttpMethod.HTTP_GET, new ActionTarget (FakeAction2));
var rh = new RouteHandler ();
rh_bad.Children.Add (new RouteHandler ("blah", HttpMethod.HTTP_GET, new ActionTarget (FakeAction)));
rh.Children.Add (rh_bad);
rh.Children.Add (rh_good);
var request = new MockHttpRequest (HttpMethod.HTTP_GET, "foobar");
var res = rh.Find (request);
Assert.AreEqual (rh_good.Target, res);
}
示例4: Find_PartialMatchAtBeginningOfChildlessHandler_ReturnsProperRoute
public void Find_PartialMatchAtBeginningOfChildlessHandler_ReturnsProperRoute()
{
IMatchOperation fooOp = MatchOperationFactory.Create("foo", MatchType.String);
IMatchOperation foobarOp = MatchOperationFactory.Create("foobar", MatchType.String);
var rh_bad = new RouteHandler(fooOp, HttpMethod.HTTP_GET, new ActionTarget(FakeAction));
var rh_good = new RouteHandler(foobarOp, HttpMethod.HTTP_GET, new ActionTarget(FakeAction2));
var rh = new RouteHandler();
rh.Add(rh_bad);
rh.Add(rh_good);
var request = new MockHttpRequest(HttpMethod.HTTP_GET, "foobar");
IManosTarget res = rh.Find(request);
Assert.AreEqual(rh_good.Target, res);
}
示例5: UriParamsTestDeep
public void UriParamsTestDeep()
{
var rh = new RouteHandler ("(?<animal>.+)/", "GET") {
new RouteHandler ("(?<name>.+)", "GET", new ActionTarget (FakeAction)),
};
var request = new MockHttpRequest ("GET", "dog/roxy");
Should.NotBeNull (rh.Find (request), "target");
Should.NotBeNull (request.UriData, "uri-data");
Assert.AreEqual ("dog", request.UriData ["animal"]);
Assert.AreEqual ("roxy", request.UriData ["name"]);
}
示例6: UriParamsTest
public void UriParamsTest()
{
var rh = new RouteHandler ("(?<name>.+)", "GET", new ActionTarget (FakeAction));
var request = new MockHttpRequest ("GET", "hello");
Should.NotBeNull (rh.Find (request), "target");
Should.NotBeNull (request.UriData, "uri-data");
Assert.AreEqual ("hello", request.UriData ["name"]);
}
示例7: TestStrMatchDeep
public void TestStrMatchDeep()
{
var target = new MockManosTarget ();
var rh = new RouteHandler ("foo/", "GET") {
new RouteHandler ("bar", "GET", target),
};
var request = new MockHttpRequest ("GET", "foo/bar");
Assert.AreEqual (target, rh.Find (request));
request = new MockHttpRequest ("GET", "foo/foo");
Assert.IsNull (rh.Find (request), "repeate-input");
request = new MockHttpRequest ("GET", "foo/badbar");
Assert.IsNull (rh.Find (request), "matched-input");
}
示例8: TestStrMatch
public void TestStrMatch()
{
var target = new MockManosTarget ();
var rh = new RouteHandler ("^foo", "GET", target);
var request = new MockHttpRequest ("GET", "foo");
Assert.AreEqual (target, rh.Find (request), "should-match");
request = new MockHttpRequest ("GET", "garbage-foo");
Assert.IsNull (rh.Find (request), "garbage-input");
}
示例9: TestSetPatternsNull
public void TestSetPatternsNull()
{
var target = new MockManosTarget ();
var rh = new RouteHandler ("^foo", "GET", target);
var request = new MockHttpRequest ("GET", "foo");
Assert.AreEqual (target, rh.Find (request), "sanity-1");
rh.Patterns = null;
Assert.IsNull (rh.Find (request), "is null");
}
示例10: UriParamsTestDeep
public void UriParamsTestDeep()
{
IMatchOperation animalOp = MatchOperationFactory.Create("(?<animal>.+)/", MatchType.Regex);
IMatchOperation nameOp = MatchOperationFactory.Create("(?<name>.+)", MatchType.Regex);
var rh = new RouteHandler(animalOp, HttpMethod.HTTP_GET)
{
new RouteHandler(nameOp, HttpMethod.HTTP_GET, new ActionTarget(FakeAction)),
};
var request = new MockHttpRequest(HttpMethod.HTTP_GET, "dog/roxy");
Should.NotBeNull(rh.Find(request), "target");
Should.NotBeNull(request.UriData, "uri-data");
Assert.AreEqual("dog", request.UriData["animal"]);
Assert.AreEqual("roxy", request.UriData["name"]);
}
示例11: UriParamsTest
public void UriParamsTest()
{
IMatchOperation fooOp = MatchOperationFactory.Create("(?<name>.+)", MatchType.Regex);
var rh = new RouteHandler(fooOp, HttpMethod.HTTP_GET, new ActionTarget(FakeAction));
var request = new MockHttpRequest(HttpMethod.HTTP_GET, "hello");
Should.NotBeNull(rh.Find(request), "target");
Should.NotBeNull(request.UriData, "uri-data");
Assert.AreEqual("hello", request.UriData["name"]);
}
示例12: TestStrMatchDeep
public void TestStrMatchDeep()
{
IMatchOperation fooOp = MatchOperationFactory.Create("foo/", MatchType.String);
IMatchOperation barOp = MatchOperationFactory.Create("bar", MatchType.String);
var target = new MockManosTarget();
var rh = new RouteHandler(fooOp, HttpMethod.HTTP_GET)
{
new RouteHandler(barOp, HttpMethod.HTTP_GET, target),
};
var request = new MockHttpRequest(HttpMethod.HTTP_GET, "foo/bar");
Assert.AreEqual(target, rh.Find(request));
request = new MockHttpRequest(HttpMethod.HTTP_GET, "foo/foo");
Assert.IsNull(rh.Find(request), "repeate-input");
request = new MockHttpRequest(HttpMethod.HTTP_GET, "foo/badbar");
Assert.IsNull(rh.Find(request), "matched-input");
}
示例13: TestStrMatch
public void TestStrMatch()
{
IMatchOperation op = MatchOperationFactory.Create("^foo", MatchType.Regex);
var target = new MockManosTarget();
var rh = new RouteHandler(op, HttpMethod.HTTP_GET, target);
var request = new MockHttpRequest(HttpMethod.HTTP_GET, "foo");
Assert.AreEqual(target, rh.Find(request), "should-match");
request = new MockHttpRequest(HttpMethod.HTTP_GET, "garbage-foo");
Assert.IsNull(rh.Find(request), "garbage-input");
}
示例14: TestSetPatternsNull
public void TestSetPatternsNull()
{
IMatchOperation fooOp = MatchOperationFactory.Create("^foo", MatchType.Regex);
var target = new MockManosTarget();
var rh = new RouteHandler(fooOp, HttpMethod.HTTP_GET, target);
var request = new MockHttpRequest(HttpMethod.HTTP_GET, "foo");
Assert.AreEqual(target, rh.Find(request), "sanity-1");
rh.MatchOps = null;
Assert.IsNull(rh.Find(request), "is null");
}
示例15: TestChangePatterns
public void TestChangePatterns()
{
//
// Ensure that changing the patterns property works.
// This is a bit of an edge case because internally
// the patterns strings are cached as an array of
// regexes.
//
IMatchOperation fooOp = MatchOperationFactory.Create("^foo", MatchType.Regex);
var target = new MockManosTarget();
var rh = new RouteHandler(fooOp, HttpMethod.HTTP_GET, target);
var request = new MockHttpRequest(HttpMethod.HTTP_GET, "foo");
Assert.AreEqual(target, rh.Find(request), "sanity-1");
rh.MatchOps[0] = MatchOperationFactory.Create("baz", MatchType.Regex);
Assert.IsNull(rh.Find(request), "sanity-2");
request = new MockHttpRequest(HttpMethod.HTTP_GET, "baz");
Assert.AreEqual(target, rh.Find(request), "changed");
}