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); }
public void TestCorrectNoRedirect() { RegexRedirectRule rule = new RegexRedirectRule("/(?<first>[a-z]+)/(?<second>[a-z]+)/?", "/test/?ignore=${second}¶meters=${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¶meters=above"); }
public void TestNullParameter4() { RegexRedirectRule regexRule = new RegexRedirectRule("nun", "nun"); Assert.Throws(typeof(ArgumentNullException), delegate { regexRule.Process(new HttpTestRequest(), null); }); }