Esempio n. 1
0
        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");
        }
Esempio n. 2
0
        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");
        }
Esempio n. 3
0
        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");
        }
Esempio n. 4
0
        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");
        }
Esempio n. 5
0
        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");
        }
Esempio n. 6
0
        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");
        }
Esempio n. 7
0
        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");
        }
Esempio n. 8
0
        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");
        }