public void RestSharpApiCallerCanCallEndpointWithSerializedParameters() { //Setup var createPostRequest = new CreatePostRequest { Text = @"@jdscolam this is another #Rapptor #testpost, with links and stuff. https://github.com/jdscolam/Rapptor and Rapptor NuGet" , ReplyTo = "197934" }; IApiCaller restSharpApiCaller = new RestSharpApiCaller(ACCESS_TOKEN); //Execute var parameters = PostsService.GetPostRequestParameters(createPostRequest); var postCreated = restSharpApiCaller.ApiPost<Post>("posts/", null, parameters.ToArray()); //Verify postCreated.Data.ShouldNotBeNull(); postCreated.Data.Id.ShouldNotBeNull(); postCreated.Data.CreatedAt.ShouldNotBeNull(); postCreated.Data.Text.ShouldNotBeNull(); postCreated.Data.Text.ShouldEqual(createPostRequest.Text); postCreated.Data.Entities.ShouldNotBeNull(); postCreated.Data.Entities.Links.ShouldNotBeNull(); postCreated.Data.Entities.Links[0].ShouldNotBeNull(); postCreated.Data.ReplyTo.ShouldNotBeNull(); postCreated.Data.ReplyTo.ShouldEqual(createPostRequest.ReplyTo); //Teardown }
public void RestSharpApiCallerCanCreatePostWithAnnotations() { //Setup var annotationValue = new MyAnnotationClass { Name = "My test parameter annotation" , Value = 23.5M }; var annotation = new Annotation { Type = "net.raptorapp.test.request.parameter" , Value = annotationValue }; var createPostRequest = new CreatePostRequest { Text = @"@jdscolam this is another #Rapptor #testpost, with links and stuff. https://github.com/jdscolam/Rapptor and Rapptor NuGet" , ReplyTo = "197934" , Annotations = new List<Annotation> { annotation } }; var postStreamGeneralParameters = new PostStreamGeneralParameters { IncludeAnnotations = 1 }; IApiCaller restSharpApiCaller = new RestSharpApiCaller(ACCESS_TOKEN); //Execute var parameters = PostsService.GetGeneralParameters(postStreamGeneralParameters).ToArray(); var postCreated = restSharpApiCaller.ApiPost<CreatePostRequest, Post>("posts/", null, createPostRequest); //Verify postCreated.Data.ShouldNotBeNull(); postCreated.Data.Id.ShouldNotBeNull(); postCreated = restSharpApiCaller.ApiGet<Post>("posts/" + postCreated.Data.Id + "/", null, requestParameters: parameters); postCreated.Data.Annotations.ShouldNotBeNull(); postCreated.Data.Annotations.ShouldHaveCount(1); postCreated.Data.Annotations.First().Type.ShouldEqual(annotation.Type); var myAnnotationObjectValue = postCreated.Data.Annotations.First().Value as MyAnnotationClass; myAnnotationObjectValue.ShouldNotBeNull(); // ReSharper disable PossibleNullReferenceException myAnnotationObjectValue.Name.ShouldEqual(annotationValue.Name); // ReSharper restore PossibleNullReferenceException myAnnotationObjectValue.Value.ShouldEqual(annotationValue.Value); //Teardown }