public async Task ReturnsReviews() { var reviews = await ReviewsEndpoint.GetRecentReviewsForAllMembers(); Assert.NotNull(reviews); Assert.True(reviews.Count > 0); }
public async Task ReturnsSortedList() { var reviews = await ReviewsEndpoint.GetListByUser( ReviewsUserId, sort : SortReviewsList.AverageRating, order : Order.Descending); Assert.NotNull(reviews); Review previousReview = null; foreach (var currentReview in reviews.List) { Assert.NotNull(currentReview); Assert.NotNull(currentReview.Book); Assert.NotNull(currentReview.Book.AverageRating); if (previousReview != null) { // TODO: Goodreads is currently returning sorted lists wrong. Disable this // assertion for now until they hopefully fix it in the future. // Assert.True(previousReview.Book.AverageRating >= currentReview.Book.AverageRating); } previousReview = currentReview; } }
public async Task ReturnsAReview() { int expectedId = 2153; var review = await ReviewsEndpoint.GetById(expectedId); Assert.NotNull(review); Assert.Equal(review.Id, expectedId); }
public async Task ReturnsCorrectPageSize() { var expectedPageSize = 42; var reviews = await ReviewsEndpoint.GetListByUser(ReviewsUserId, pageSize : expectedPageSize); Assert.NotNull(reviews); Assert.Equal(reviews.Pagination.End, expectedPageSize); Assert.Equal(reviews.List.Count, expectedPageSize); }
public async Task ReturnsAReview() { var expectedBookId = 68428; var review = await ReviewsEndpoint.GetByUserIdAndBookId(UserId, expectedBookId); Assert.NotNull(review); Assert.NotNull(review.Book); Assert.NotNull(review.User); Assert.Equal(review.User.Id, UserId); Assert.Equal(review.Book.Id, expectedBookId); }
public async Task ReturnsAReviewOnADifferentEdition() { var expectedBookId = 68428; var differentEditionBookId = 243272; var review = await ReviewsEndpoint.GetByUserIdAndBookId( UserId, differentEditionBookId, findReviewOnDifferentEdition : true); Assert.NotNull(review); Assert.NotNull(review.Book); Assert.NotNull(review.User); Assert.Equal(review.User.Id, UserId); Assert.Equal(review.Book.Id, expectedBookId); }
public async Task EditReviewTextSucceeds() { const long EditReviewId = 2175139156; var expectedNewText = "test_" + _rand.Next(); var result = await ReviewsEndpoint.Edit(EditReviewId, expectedNewText, null, null, null); Assert.True(result); var reviewAfterEdit = await ReviewsEndpoint.GetById(EditReviewId); var actualNewText = reviewAfterEdit.Body.Trim(); Assert.Equal(expectedNewText, actualNewText); }
public UnauthorizedGoodreadsClient(string apiKey, string apiSecret, string accessToken, string accessSecret) : base(apiKey, apiSecret, accessToken, accessSecret) { Authors = new AuthorsEnpoint(_connection); Books = new BooksEndpoint(_connection); Shelves = new ShelvesEndpoint(_connection); Users = new UsersEndpoint(_connection); Reviews = new ReviewsEndpoint(_connection); Series = new SeriesEndpoint(_connection); Events = new EventsEndpoint(_connection); Groups = new GroupsEndpoint(_connection); UserStatuses = new UserStatusesEndpoint(_connection); ReadStatuses = new ReadStatusesEndpoint(_connection); Comments = new CommentsEndpoint(_connection); Topics = new TopicsEndpoint(_connection); }
public async Task EditRatingSucceeds() { const long EditReviewId = 1700138017; var reviewBeforeEdit = await ReviewsEndpoint.GetById(EditReviewId); var ratingBeforeEdit = reviewBeforeEdit.Rating; var expectedNewRating = ratingBeforeEdit == 5 ? 4 : 5; var result = await ReviewsEndpoint.Edit(EditReviewId, string.Empty, expectedNewRating, null, null); Assert.True(result); var reviewAfterEdit = await ReviewsEndpoint.GetById(EditReviewId); var actualRatingAfterEdit = reviewAfterEdit.Rating; Assert.Equal(expectedNewRating, actualRatingAfterEdit); }
public async Task EditReadDateSucceeds() { const long EditReviewId = 2034600714; var reviewBeforeEdit = await ReviewsEndpoint.GetById(EditReviewId); var dateBeforeEdit = reviewBeforeEdit.DateRead; var expectedNewDate = dateBeforeEdit.GetValueOrDefault().Date >= DateTime.UtcNow.Date ? DateTime.UtcNow.Date.AddDays(-7) : DateTime.UtcNow.Date; var result = await ReviewsEndpoint.Edit(EditReviewId, string.Empty, null, expectedNewDate, null); Assert.True(result); var reviewAfterEdit = await ReviewsEndpoint.GetById(EditReviewId); var actualNewDate = reviewAfterEdit.DateRead; Assert.NotNull(actualNewDate); Assert.True(dateBeforeEdit.Value.Date != actualNewDate.Value.Date); }
public OAuthGoodreadsClient(string apiKey, string apiSecret, string accessToken, string accessSecret) : base(apiKey, apiSecret, accessToken, accessSecret) { Authors = new AuthorsEnpoint(_connection); AuthorsFollowing = new AuthorsFollowingEndpoint(_connection); Books = new BooksEndpoint(_connection); Comments = new CommentsEndpoint(_connection); Events = new EventsEndpoint(_connection); Followers = new FollowersEndpoint(_connection); Friends = new FriendsEndpoint(_connection); Groups = new GroupsEndpoint(_connection); Notifications = new NotificationsEndpoint(_connection); OwnedBooks = new OwnedBooksEndpoint(_connection); Quotes = new QuotesEndpoint(_connection); ReadStatuses = new ReadStatusesEndpoint(_connection); Recommendations = new RecommendationsEndpoint(_connection); Reviews = new ReviewsEndpoint(_connection); Series = new SeriesEndpoint(_connection); Shelves = new ShelvesEndpoint(_connection); Topics = new TopicsEndpoint(_connection); Updates = new UpdatesEndpoint(_connection); Users = new UsersEndpoint(_connection); UserStatuses = new UserStatusesEndpoint(_connection); }
public async Task ReturnsReviews() { var reviews = await ReviewsEndpoint.GetListByUser(ReviewsUserId); Assert.NotNull(reviews); }
public async Task ReturnsNullIfCannotCreate() { var reviewId = await ReviewsEndpoint.Create(int.MaxValue, string.Empty, null, null, null); Assert.Null(reviewId); }