public void Can_deserialize_SimpleType_in_middle_of_path() { var restPath = new RestPath(typeof(SimpleType), "/simple/{Name}/some-other-literal"); var request = restPath.CreateRequest("/simple/HelloWorld!/some-other-literal") as SimpleType; Assert.That(request, Is.Not.Null); Assert.That(request.Name, Is.EqualTo("HelloWorld!")); }
public static object CreateRequest(IRequest httpReq, RestPath restPath, Dictionary <string, string> requestParams, object requestDto) { string contentType; var pathInfo = !restPath.IsWildCardPath ? GetSanitizedPathInfo(httpReq.PathInfo, out contentType) : httpReq.PathInfo; return(restPath.CreateRequest(pathInfo, requestParams, requestDto)); }
public void Can_deserialize_ComplexType_path() { var restPath = new RestPath(typeof(ComplexType), "/Complex/{Id}/{Name}/Unique/{UniqueId}"); var request = restPath.CreateRequest( "/complex/5/Is Alive/unique/4583B364-BBDC-427F-A289-C2923DEBD547") as ComplexType; Assert.That(request, Is.Not.Null); Assert.That(request.Id, Is.EqualTo(5)); Assert.That(request.Name, Is.EqualTo("Is Alive")); Assert.That(request.UniqueId, Is.EqualTo(new Guid("4583B364-BBDC-427F-A289-C2923DEBD547"))); }
private static void AssertMatch(string definitionPath, string requestPath, string firstMatchHashKey, SlugRequest expectedRequest, int expectedScore) { var restPath = new RestPath(typeof(SlugRequest), definitionPath); var requestTestPath = RestPath.GetPathPartsForMatching(requestPath); Assert.That(restPath.IsMatch("GET", requestTestPath), Is.True); Assert.That(firstMatchHashKey, Is.EqualTo(restPath.FirstMatchHashKey)); var actualRequest = restPath.CreateRequest(requestPath) as SlugRequest; Assert.That(actualRequest, Is.Not.Null); Assert.That(actualRequest.Slug, Is.EqualTo(expectedRequest.Slug)); Assert.That(actualRequest.Version, Is.EqualTo(expectedRequest.Version)); Assert.That(actualRequest.Options, Is.EqualTo(expectedRequest.Options)); Assert.That(restPath.MatchScore("GET", requestTestPath), Is.EqualTo(expectedScore)); }
private static void AssertMatch(string definitionPath, string requestPath, string firstMatchHashKey, RackSpaceRequest expectedRequest) { var restPath = new RestPath(typeof(RackSpaceRequest), definitionPath); var reqestTestPath = RestPath.GetPathPartsForMatching(requestPath); Assert.That(restPath.IsMatch("GET", reqestTestPath), Is.True); Assert.That(firstMatchHashKey, Is.EqualTo(restPath.FirstMatchHashKey)); var actualRequest = restPath.CreateRequest(requestPath) as RackSpaceRequest; Assert.That(actualRequest, Is.Not.Null); Assert.That(actualRequest.version, Is.EqualTo(expectedRequest.version)); Assert.That(actualRequest.id, Is.EqualTo(expectedRequest.id)); Assert.That(actualRequest.resource_type, Is.EqualTo(expectedRequest.resource_type)); Assert.That(actualRequest.action, Is.EqualTo(expectedRequest.action)); }
private static void AssertMatch(string definitionPath, string requestPath, string firstMatchHashKey, BbcMusicRequest expectedRequest) { var restPath = new RestPath(typeof(BbcMusicRequest), definitionPath); var reqestTestPath = RestPath.GetPathPartsForMatching(requestPath); Assert.That(restPath.IsMatch("GET", reqestTestPath), Is.True); Assert.That(firstMatchHashKey, Is.EqualTo(restPath.FirstMatchHashKey)); var actualRequest = restPath.CreateRequest(requestPath) as BbcMusicRequest; Assert.That(actualRequest, Is.Not.Null); Assert.That(actualRequest.mbz_guid, Is.EqualTo(expectedRequest.mbz_guid)); Assert.That(actualRequest.release_type, Is.EqualTo(expectedRequest.release_type)); Assert.That(actualRequest.content_type, Is.EqualTo(expectedRequest.content_type)); }
public void Can_include_StaticValuesForVariables_request() { using (JsConfig.With(includePublicFields: true)) { var variableBindings = new Dictionary<string, object> { {"Id", 5}, {"Name", "Is Alive"} }; var restPath = new RestPath(typeof (ComplexTypeWithFields), "/Complex/Unique/{UniqueId}", null, null, null, variableBindings); var request = restPath.CreateRequest( "/complex/unique/4583B364-BBDC-427F-A289-C2923DEBD547") as ComplexTypeWithFields; Assert.That(request, Is.Not.Null); Assert.That(request.Id, Is.EqualTo(5)); Assert.That(request.Name, Is.EqualTo("Is Alive")); Assert.That(request.UniqueId, Is.EqualTo(new Guid("4583B364-BBDC-427F-A289-C2923DEBD547"))); } }