public void GivenPath_RootSegmentsContainFirstPartOfPath() { var routes = new List <RequestBuilder> { new RequestBuilder(HttpMethod.Get, "/api/foo/bar", null) }; var dictionary = RouteDictionary.From(routes); dictionary .RootSegments .Should() .ContainKey("api"); }
public void GivenPathForSingleDocumentAtRoot_RootSegmentContainsRequestBuilder() { var requestBuilder = new RequestBuilder(HttpMethod.Post, "/index.php", null); var routes = new List <RequestBuilder> { requestBuilder }; var dictionary = RouteDictionary.From(routes); dictionary .RootSegments["index.php"] .RequestBuilders[HttpMethod.Post] .Should() .Be(requestBuilder); }
public void GivenRouteWithParameterAndQueryStringWithoutSeparatorX_RequestBuilderIsReturned() { var routes = new List <RequestBuilder> { new RequestBuilder(HttpMethod.Get, "/api/foos/{id}?blah=baz", null), new RequestBuilder(HttpMethod.Get, "/api/foos/{id}?blah=qux", null) }; var dictionary = RouteDictionary.From(routes); dictionary .Match( HttpMethod.Get, "/api/foos/1234?blah=qux") .Should() .Be(routes[1]); }
public void GivenRouteWithParameterAndQueryString_RequestBuilderIsReturned() { var requestBuilder = new RequestBuilder(HttpMethod.Get, "/api/foos/{id}/?blah=baz", null); var routes = new List <RequestBuilder> { requestBuilder }; var dictionary = RouteDictionary.From(routes); dictionary .Match( HttpMethod.Get, "/api/foos/1234/?blah=baz") .Should() .Be(requestBuilder); }
public void GivenNonConfigured_NoResultIsReturned() { var requestBuilder = new RequestBuilder(HttpMethod.Get, "/api/foo/bar?blah=blurb", null); var routes = new List <RequestBuilder> { requestBuilder }; var dictionary = RouteDictionary.From(routes); dictionary .Match( HttpMethod.Get, "/api/baz") .Should() .BeNull(); }
public void GivenPathWithQueryParameters_ReturnedRequestBuilderMatches() { var requestBuilder = new RequestBuilder(HttpMethod.Get, "/api/foo/bar?blah=blurb", null); var routes = new List <RequestBuilder> { requestBuilder }; var dictionary = RouteDictionary.From(routes); dictionary .Match( HttpMethod.Get, "/api/foo/bar?blah=blurb") .Should() .Be(requestBuilder); }
public void GivenPathWithQueryParameters_TailSegmentContainsRequestBuilder() { var requestBuilder = new RequestBuilder(HttpMethod.Get, "/api/foo/bar?blah=blurb", null); var routes = new List <RequestBuilder> { requestBuilder }; var dictionary = RouteDictionary.From(routes); dictionary .RootSegments["api"] .Segments["foo"] .Segments["bar?blah=blurb"] .RequestBuilders[HttpMethod.Get] .Should() .Be(requestBuilder); }