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 UsersServiceCanRetrieveFollowersOnMe() { //Setup const string userId = "me"; var restSharpApiCaller = new RestSharpApiCaller(ACCESS_TOKEN); var usersService = new UsersService(restSharpApiCaller); //Execute var myFollowers = usersService.GetFollowers(userId); //Verify myFollowers.Data.ShouldNotBeNull(); myFollowers.Data.Count().ShouldBeGreaterThan(0); //Teardown }
public void UsersServiceCanRetrieveFollowersByUserId() { //Setup const string userId = "1"; //NOTE: This is @dalton's userId so it will take FOREVER to return, but it will return. var restSharpApiCaller = new RestSharpApiCaller(ACCESS_TOKEN); var usersService = new UsersService(restSharpApiCaller); //Execute var followers = usersService.GetFollowers(userId); //Verify followers.Data.ShouldNotBeNull(); followers.Data.Count().ShouldBeGreaterThan(0); //Teardown }
public void UsersServiceCanListUsersWhoHaveStarredAPost() { //Setup const string postId = "1"; var restSharpApiCaller = new RestSharpApiCaller(ACCESS_TOKEN); var usersService = new UsersService(restSharpApiCaller); //Execute var starringUsers = usersService.ListUsersWhoHaveStarredPost(postId); //Verify starringUsers.Data.ShouldNotBeNull(); starringUsers.Data.Count.ShouldBeGreaterThan(0); //Teardown }
public void PostsServiceCanListPostsStarredByAUser() { //Setup const string userId = "me"; var restSharpApiCaller = new RestSharpApiCaller(ACCESS_TOKEN); var postsService = new PostsService(restSharpApiCaller); //Execute var starredPosts = postsService.RetrievePostsStarredByUser(userId); //Verify starredPosts.Data.ShouldNotBeNull(); starredPosts.Data.Count.ShouldBeGreaterThan(0); foreach (var post in starredPosts.Data) { post.YouStarred.HasValue.ShouldBeTrue(); // ReSharper disable PossibleInvalidOperationException post.YouStarred.Value.ShouldBeTrue(); // ReSharper restore PossibleInvalidOperationException } //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 }
public void RestSharpApiCallerCanGetSimpleEndpoint() { //Setup IApiCaller restSharpApiCaller = new RestSharpApiCaller(ACCESS_TOKEN); //Execute var tokenInfo = restSharpApiCaller.ApiGet<TokenInfo>("token", null); //Verify tokenInfo.Data.ShouldNotBeNull(); tokenInfo.Data.User.ShouldNotBeNull(); tokenInfo.Data.User.Description.ShouldNotBeNull(); tokenInfo.Data.User.Counts.ShouldNotBeNull(); //Teardown }
public void RestSharpApiCallerCanGetEndpointWithVariable() { //Setup const string userId = "1"; IApiCaller restSharpApiCaller = new RestSharpApiCaller(ACCESS_TOKEN); //Execute var user = restSharpApiCaller.ApiGet<User>("users/" + userId, null); //Verify user.Data.ShouldNotBeNull(); user.Data.Description.ShouldNotBeNull(); user.Data.Counts.ShouldNotBeNull(); //Teardown }
public void RestSharpApiCallerCanGetEndpointWithFilterParameters() { //Setup const string postId = "197934"; var postStreamGeneralParameters = new PostStreamGeneralParameters { SinceId = "199732" }; IApiCaller restSharpApiCaller = new RestSharpApiCaller(ACCESS_TOKEN); var requestParameters = PostsService.GetGeneralParameters(postStreamGeneralParameters); //Execute var filteredPosts = restSharpApiCaller.ApiGet<List<Post>>("posts/" + postId + "/" + PostsService.REPLIES_ACTION, null, requestParameters.ToArray()); //Verify filteredPosts.ShouldNotBeNull(); foreach (var reply in filteredPosts.Data) { reply.Id.ShouldBeGreaterThan(postStreamGeneralParameters.SinceId); reply.ThreadId.ShouldEqual(postId); } //Teardown }