public async Task Test_CommentObjectJsonReader_ReadObject_From_Json_String_Not_Valid_5() { var jsonReader = new CommentObjectJsonReader(); var traktComment = await jsonReader.ReadObjectAsync(JSON_NOT_VALID_5); traktComment.Should().NotBeNull(); traktComment.Id.Should().Be(76957U); traktComment.ParentId.Should().Be(1234U); traktComment.CreatedAt.Should().Be(DateTime.Parse("2016-04-01T12:44:40Z").ToUniversalTime()); traktComment.UpdatedAt.Should().Be(DateTime.Parse("2016-04-03T08:23:38Z").ToUniversalTime()); traktComment.Comment.Should().BeNull(); traktComment.Spoiler.Should().BeFalse(); traktComment.Review.Should().BeFalse(); traktComment.Replies.Should().Be(1); traktComment.Likes.Should().Be(2); traktComment.UserRating.Should().Be(7.3f); traktComment.User.Should().NotBeNull(); traktComment.User.Username.Should().Be("sean"); traktComment.User.IsPrivate.Should().BeFalse(); traktComment.User.Name.Should().Be("Sean Rudford"); traktComment.User.IsVIP.Should().BeTrue(); traktComment.User.IsVIP_EP.Should().BeTrue(); traktComment.User.Ids.Should().NotBeNull(); traktComment.User.Ids.Slug.Should().Be("sean"); }
public async Task Test_CommentObjectJsonReader_ReadObject_From_Json_String_Incomplete_3() { var jsonReader = new CommentObjectJsonReader(); var traktComment = await jsonReader.ReadObjectAsync(JSON_INCOMPLETE_3); traktComment.Should().NotBeNull(); traktComment.Id.Should().Be(76957U); traktComment.ParentId.Should().Be(1234U); traktComment.CreatedAt.Should().Be(default(DateTime)); traktComment.UpdatedAt.Should().Be(DateTime.Parse("2016-04-03T08:23:38Z").ToUniversalTime()); traktComment.Comment.Should().Be("I hate they made The flash a kids show. Could else be much better. And with a better flash offcourse."); traktComment.Spoiler.Should().BeFalse(); traktComment.Review.Should().BeFalse(); traktComment.Replies.Should().Be(1); traktComment.Likes.Should().Be(2); traktComment.UserRating.Should().Be(7.3f); traktComment.User.Should().NotBeNull(); traktComment.User.Username.Should().Be("sean"); traktComment.User.IsPrivate.Should().BeFalse(); traktComment.User.Name.Should().Be("Sean Rudford"); traktComment.User.IsVIP.Should().BeTrue(); traktComment.User.IsVIP_EP.Should().BeTrue(); traktComment.User.Ids.Should().NotBeNull(); traktComment.User.Ids.Slug.Should().Be("sean"); }
public void Test_CommentObjectJsonReader_ReadObject_From_Json_String_Null() { var jsonReader = new CommentObjectJsonReader(); Func <Task <ITraktComment> > traktComment = () => jsonReader.ReadObjectAsync(default(string)); traktComment.Should().Throw <ArgumentNullException>(); }
public async Task Test_CommentObjectJsonReader_ReadObject_From_Json_String_Incomplete_22() { var jsonReader = new CommentObjectJsonReader(); var traktComment = await jsonReader.ReadObjectAsync(JSON_INCOMPLETE_22); traktComment.Should().NotBeNull(); traktComment.Id.Should().Be(0U); traktComment.ParentId.Should().BeNull(); traktComment.CreatedAt.Should().Be(default(DateTime)); traktComment.UpdatedAt.Should().BeNull(); traktComment.Comment.Should().BeNull(); traktComment.Spoiler.Should().BeFalse(); traktComment.Review.Should().BeFalse(); traktComment.Replies.Should().BeNull(); traktComment.Likes.Should().BeNull(); traktComment.UserRating.Should().BeNull(); traktComment.User.Should().NotBeNull(); traktComment.User.Username.Should().Be("sean"); traktComment.User.IsPrivate.Should().BeFalse(); traktComment.User.Name.Should().Be("Sean Rudford"); traktComment.User.IsVIP.Should().BeTrue(); traktComment.User.IsVIP_EP.Should().BeTrue(); traktComment.User.Ids.Should().NotBeNull(); traktComment.User.Ids.Slug.Should().Be("sean"); }
public async Task Test_CommentObjectJsonReader_ReadObject_From_Json_String_Empty() { var jsonReader = new CommentObjectJsonReader(); var traktComment = await jsonReader.ReadObjectAsync(string.Empty); traktComment.Should().BeNull(); }
public override async Task <ITraktUserLikeItem> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { if (jsonReader == null) { return(await Task.FromResult(default(ITraktUserLikeItem))); } if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var commentReader = new CommentObjectJsonReader(); var listReader = new ListObjectJsonReader(); ITraktUserLikeItem traktUserLikeItem = new TraktUserLikeItem(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.USER_LIKE_ITEM_PROPERTY_NAME_LIKED_AT: { var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken); if (value.First) { traktUserLikeItem.LikedAt = value.Second; } break; } case JsonProperties.USER_LIKE_ITEM_PROPERTY_NAME_TYPE: traktUserLikeItem.Type = await JsonReaderHelper.ReadEnumerationValueAsync <TraktUserLikeType>(jsonReader, cancellationToken); break; case JsonProperties.USER_LIKE_ITEM_PROPERTY_NAME_COMMENT: traktUserLikeItem.Comment = await commentReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.USER_LIKE_ITEM_PROPERTY_NAME_LIST: traktUserLikeItem.List = await listReader.ReadObjectAsync(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktUserLikeItem); } return(await Task.FromResult(default(ITraktUserLikeItem))); }
public async Task Test_CommentObjectJsonReader_ReadObject_From_Json_String_Not_Valid_12() { var jsonReader = new CommentObjectJsonReader(); var traktComment = await jsonReader.ReadObjectAsync(JSON_NOT_VALID_12); traktComment.Should().NotBeNull(); traktComment.Id.Should().Be(0U); traktComment.ParentId.Should().BeNull(); traktComment.CreatedAt.Should().Be(default(DateTime)); traktComment.UpdatedAt.Should().BeNull(); traktComment.Comment.Should().BeNull(); traktComment.Spoiler.Should().BeFalse(); traktComment.Review.Should().BeFalse(); traktComment.Replies.Should().BeNull(); traktComment.Likes.Should().BeNull(); traktComment.UserRating.Should().BeNull(); traktComment.User.Should().BeNull(); }
public async Task Test_CommentObjectJsonReader_ReadObject_From_Json_String_Not_Valid_11() { var jsonReader = new CommentObjectJsonReader(); var traktComment = await jsonReader.ReadObjectAsync(JSON_NOT_VALID_11); traktComment.Should().NotBeNull(); traktComment.Id.Should().Be(76957U); traktComment.ParentId.Should().Be(1234U); traktComment.CreatedAt.Should().Be(DateTime.Parse("2016-04-01T12:44:40Z").ToUniversalTime()); traktComment.UpdatedAt.Should().Be(DateTime.Parse("2016-04-03T08:23:38Z").ToUniversalTime()); traktComment.Comment.Should().Be("I hate they made The flash a kids show. Could else be much better. And with a better flash offcourse."); traktComment.Spoiler.Should().BeFalse(); traktComment.Review.Should().BeFalse(); traktComment.Replies.Should().Be(1); traktComment.Likes.Should().Be(2); traktComment.UserRating.Should().Be(7.3f); traktComment.User.Should().BeNull(); }
public async Task Test_CommentObjectJsonReader_ReadObject_From_Json_String_Incomplete_21() { var jsonReader = new CommentObjectJsonReader(); var traktComment = await jsonReader.ReadObjectAsync(JSON_INCOMPLETE_21); traktComment.Should().NotBeNull(); traktComment.Id.Should().Be(0U); traktComment.ParentId.Should().BeNull(); traktComment.CreatedAt.Should().Be(default(DateTime)); traktComment.UpdatedAt.Should().BeNull(); traktComment.Comment.Should().BeNull(); traktComment.Spoiler.Should().BeFalse(); traktComment.Review.Should().BeFalse(); traktComment.Replies.Should().BeNull(); traktComment.Likes.Should().BeNull(); traktComment.UserRating.Should().Be(7.3f); traktComment.User.Should().BeNull(); }
public async Task Test_CommentObjectJsonReader_ReadObject_From_Json_String_Incomplete_16() { var jsonReader = new CommentObjectJsonReader(); var traktComment = await jsonReader.ReadObjectAsync(JSON_INCOMPLETE_16); traktComment.Should().NotBeNull(); traktComment.Id.Should().Be(0U); traktComment.ParentId.Should().BeNull(); traktComment.CreatedAt.Should().Be(default(DateTime)); traktComment.UpdatedAt.Should().BeNull(); traktComment.Comment.Should().Be("I hate they made The flash a kids show. Could else be much better. And with a better flash offcourse."); traktComment.Spoiler.Should().BeFalse(); traktComment.Review.Should().BeFalse(); traktComment.Replies.Should().BeNull(); traktComment.Likes.Should().BeNull(); traktComment.UserRating.Should().BeNull(); traktComment.User.Should().BeNull(); }
public async Task Test_CommentObjectJsonReader_ReadObject_From_Json_String_Incomplete_15() { var jsonReader = new CommentObjectJsonReader(); var traktComment = await jsonReader.ReadObjectAsync(JSON_INCOMPLETE_15); traktComment.Should().NotBeNull(); traktComment.Id.Should().Be(0U); traktComment.ParentId.Should().BeNull(); traktComment.CreatedAt.Should().Be(default(DateTime)); traktComment.UpdatedAt.Should().Be(DateTime.Parse("2016-04-03T08:23:38Z").ToUniversalTime()); traktComment.Comment.Should().BeNull(); traktComment.Spoiler.Should().BeFalse(); traktComment.Review.Should().BeFalse(); traktComment.Replies.Should().BeNull(); traktComment.Likes.Should().BeNull(); traktComment.UserRating.Should().BeNull(); traktComment.User.Should().BeNull(); }
public override async Task <ITraktUserComment> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { if (jsonReader == null) { return(await Task.FromResult(default(ITraktUserComment))); } if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var commentReader = new CommentObjectJsonReader(); var movieReader = new MovieObjectJsonReader(); var showReader = new ShowObjectJsonReader(); var seasonReader = new SeasonObjectJsonReader(); var episodeReader = new EpisodeObjectJsonReader(); var listReader = new ListObjectJsonReader(); ITraktUserComment traktUserComment = new TraktUserComment(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.USER_COMMENT_PROPERTY_NAME_TYPE: traktUserComment.Type = await JsonReaderHelper.ReadEnumerationValueAsync <TraktObjectType>(jsonReader, cancellationToken); break; case JsonProperties.USER_COMMENT_PROPERTY_NAME_COMMENT: traktUserComment.Comment = await commentReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.USER_COMMENT_PROPERTY_NAME_MOVIE: traktUserComment.Movie = await movieReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.USER_COMMENT_PROPERTY_NAME_SHOW: traktUserComment.Show = await showReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.USER_COMMENT_PROPERTY_NAME_SEASON: traktUserComment.Season = await seasonReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.USER_COMMENT_PROPERTY_NAME_EPISODE: traktUserComment.Episode = await episodeReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.USER_COMMENT_PROPERTY_NAME_LIST: traktUserComment.List = await listReader.ReadObjectAsync(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktUserComment); } return(await Task.FromResult(default(ITraktUserComment))); }