当前位置: 首页>>代码示例>>C#>>正文


C# RouteHandler.Find方法代码示例

本文整理汇总了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");
        }
开发者ID:KevinT,项目名称:manos,代码行数:21,代码来源:RouteHandlerTest.cs

示例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);
        }
开发者ID:KevinT,项目名称:manos,代码行数:14,代码来源:RouteHandlerTest.cs

示例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);
        }
开发者ID:vbatz258,项目名称:manos,代码行数:16,代码来源:RouteHandlerTest.cs

示例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);
        }
开发者ID:nuxleus,项目名称:manos,代码行数:16,代码来源:RouteHandlerTest.cs

示例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"]);
        }
开发者ID:KevinT,项目名称:manos,代码行数:14,代码来源:RouteHandlerTest.cs

示例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"]);
        }
开发者ID:KevinT,项目名称:manos,代码行数:11,代码来源:RouteHandlerTest.cs

示例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");
        }
开发者ID:KevinT,项目名称:manos,代码行数:16,代码来源:RouteHandlerTest.cs

示例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");
        }
开发者ID:KevinT,项目名称:manos,代码行数:11,代码来源:RouteHandlerTest.cs

示例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");
        }
开发者ID:KevinT,项目名称:manos,代码行数:12,代码来源:RouteHandlerTest.cs

示例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"]);
        }
开发者ID:nuxleus,项目名称:manos,代码行数:18,代码来源:RouteHandlerTest.cs

示例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"]);
        }
开发者ID:nuxleus,项目名称:manos,代码行数:12,代码来源:RouteHandlerTest.cs

示例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");
        }
开发者ID:nuxleus,项目名称:manos,代码行数:19,代码来源:RouteHandlerTest.cs

示例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");
        }
开发者ID:nuxleus,项目名称:manos,代码行数:12,代码来源:RouteHandlerTest.cs

示例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");
        }
开发者ID:nuxleus,项目名称:manos,代码行数:14,代码来源:RouteHandlerTest.cs

示例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");
        }
开发者ID:nuxleus,项目名称:manos,代码行数:22,代码来源:RouteHandlerTest.cs


注:本文中的RouteHandler.Find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。