public void SetUp() { _generator = new MostMatchingRestrictionsGenerator(); _request = MockRepository.GenerateMock <HttpRequestBase>(); _request.Stub(arg => arg.Url).Return(new Uri("http://localhost")); _request.Stub(arg => arg.HttpMethod).Return("GET"); _response = MockRepository.GenerateMock <HttpResponseBase>(); _context = MockRepository.GenerateMock <HttpContextBase>(); _context.Stub(arg => arg.Request).Return(_request); _context.Stub(arg => arg.Response).Return(_response); _route1Response = new Response(200); _route1 = new Route.Routing.Route("name1", Guid.NewGuid(), "relative1"); _route1.RestrictByMethods(HttpMethod.Get); _route1.RespondWith(_route1Response); _route2Response = new Response(200); _route2 = new Route.Routing.Route("name2", Guid.NewGuid(), "relative2"); _route2.RestrictByMethods(HttpMethod.Get); _route2.RestrictByUrl(uri => true); _route2.RespondWith(_route2Response); _routeMatchResults = new[] { new RouteMatchResult(_route1, _route1.MatchesRequestAsync(_request).Result), new RouteMatchResult(_route2, _route2.MatchesRequestAsync(_request).Result) }; }
public void SetUp() { _generator = new MostMatchingRestrictionsGenerator(); _request = MockRepository.GenerateMock<HttpRequestBase>(); _request.Stub(arg => arg.Url).Return(new Uri("http://localhost")); _request.Stub(arg => arg.HttpMethod).Return("GET"); _response = MockRepository.GenerateMock<HttpResponseBase>(); _context = MockRepository.GenerateMock<HttpContextBase>(); _context.Stub(arg => arg.Request).Return(_request); _context.Stub(arg => arg.Response).Return(_response); _route1Response = new Response(200); _route1 = new Route.Routing.Route("name1", Guid.NewGuid(), "relative1"); _route1.RestrictByMethods(HttpMethod.Get); _route1.RespondWith(_route1Response); _route2Response = new Response(200); _route2 = new Route.Routing.Route("name2", Guid.NewGuid(), "relative2"); _route2.RestrictByMethods(HttpMethod.Get); _route2.RestrictByUrl(uri => true); _route2.RespondWith(_route2Response); _routeMatchResults = new[] { new RouteMatchResult(_route1, _route1.MatchesRequestAsync(_request).Result), new RouteMatchResult(_route2, _route2.MatchesRequestAsync(_request).Result) }; }
public void SetUp() { _route = new Route.Routing.Route("name", Guid.NewGuid(), "route"); _route.AddRestrictions(new UrlHostRestriction("host", CaseInsensitivePlainComparer.Instance), new UrlPortRestriction(80)); _request = MockRepository.GenerateMock<HttpRequestBase>(); _request.Stub(arg => arg.Url).Return(new Uri("http://host:81")); _matchResult = _route.MatchesRequestAsync(_request).Result; }