コード例 #1
0
        public void TestCorrect()
        {
            RegexRedirectRule rule    = new RegexRedirectRule("/(?<first>[a-z]+)/(?<second>[a-z]+/?)", "/test/?parameter=${second}&ignore=${first}", RegexOptions.IgnoreCase);
            IHttpRequest      request = new HttpTestRequest
            {
                HttpVersion = "1.0",
                Uri         = new Uri("http://www.google.com/above/all/", UriKind.Absolute)
            };
            IHttpResponse response = request.CreateResponse(new HttpContext());

            rule.Process(request, response);
            Assert.Equal(HttpStatusCode.Redirect, response.Status);
        }
コード例 #2
0
        public void TestCorrectNoRedirect()
        {
            RegexRedirectRule rule    = new RegexRedirectRule("/(?<first>[a-z]+)/(?<second>[a-z]+)/?", "/test/?ignore=${second}&parameters=${first}", RegexOptions.IgnoreCase, false);
            IHttpRequest      request = new HttpTestRequest
            {
                HttpVersion = "1.0",
                Uri         = new Uri("http://www.google.com/above/all/", UriKind.Absolute)
            };
            IHttpResponse response = request.CreateResponse(new HttpContext());

            rule.Process(request, response);
            Assert.Equal(request.Uri.ToString(), "http://www.google.com/test/?ignore=all&parameters=above");
        }
コード例 #3
0
        public void TestNullParameter4()
        {
            RegexRedirectRule regexRule = new RegexRedirectRule("nun", "nun");

            Assert.Throws(typeof(ArgumentNullException), delegate { regexRule.Process(new HttpTestRequest(), null); });
        }