public async Task Test_TraktCommentsModule_PostSeasonComment_ArgumentExceptions() { ITraktSeason season = new TraktSeason { Ids = new TraktSeasonIds { Trakt = 3950, Tvdb = 30272, Tmdb = 3572 } }; ITraktSeasonCommentPost seasonCommentPost = new TraktSeasonCommentPost { Season = season, Comment = COMMENT_TEXT }; string postJson = await TestUtility.SerializeObject(seasonCommentPost); postJson.Should().NotBeNullOrEmpty(); TraktClient client = TestUtility.GetOAuthMockClient(POST_SEASON_COMMENT_URI, postJson, COMMENT_POST_RESPONSE_JSON); Func <Task <TraktResponse <ITraktCommentPostResponse> > > act = () => client.Comments.PostSeasonCommentAsync(null, COMMENT_TEXT); await act.Should().ThrowAsync <ArgumentNullException>(); season.Ids = null; act = () => client.Comments.PostSeasonCommentAsync(season, COMMENT_TEXT); await act.Should().ThrowAsync <ArgumentNullException>(); season.Ids = new TraktSeasonIds(); act = () => client.Comments.PostSeasonCommentAsync(season, COMMENT_TEXT); await act.Should().ThrowAsync <ArgumentException>(); season.Ids = new TraktSeasonIds { Trakt = 3950, Tvdb = 30272, Tmdb = 3572 }; act = () => client.Comments.PostSeasonCommentAsync(season, null); await act.Should().ThrowAsync <ArgumentException>(); act = () => client.Comments.PostSeasonCommentAsync(season, string.Empty); await act.Should().ThrowAsync <ArgumentException>(); const string comment = "one two three four"; act = () => client.Comments.PostSeasonCommentAsync(season, comment); await act.Should().ThrowAsync <ArgumentOutOfRangeException>(); }
public async Task Test_TraktCommentsModule_PostSeasonComment_Complete() { ITraktSeasonCommentPost seasonCommentPost = new TraktSeasonCommentPost { Season = Season, Comment = COMMENT_TEXT, Spoiler = SPOILER, Sharing = SHARING }; string postJson = await TestUtility.SerializeObject(seasonCommentPost); postJson.Should().NotBeNullOrEmpty(); TraktClient client = TestUtility.GetOAuthMockClient(POST_SEASON_COMMENT_URI, postJson, COMMENT_POST_RESPONSE_JSON); TraktResponse <ITraktCommentPostResponse> response = await client.Comments.PostSeasonCommentAsync(Season, COMMENT_TEXT, SPOILER, SHARING); response.Should().NotBeNull(); response.IsSuccess.Should().BeTrue(); response.HasValue.Should().BeTrue(); response.Value.Should().NotBeNull(); ITraktCommentPostResponse responseValue = response.Value; responseValue.Id.Should().Be(COMMENT_ID); responseValue.ParentId.Should().Be(0U); responseValue.CreatedAt.Should().Be(DateTime.Parse("2014-08-04T06:46:01.996Z").ToUniversalTime()); responseValue.Comment.Should().Be("Oh, I wasn't really listening."); responseValue.Spoiler.Should().BeFalse(); responseValue.Review.Should().BeFalse(); responseValue.Replies.Should().Be(0); responseValue.Likes.Should().Be(0); responseValue.UserRating.Should().NotHaveValue(); responseValue.User.Should().NotBeNull(); responseValue.User.Username.Should().Be("sean"); responseValue.User.IsPrivate.Should().BeFalse(); responseValue.User.Name.Should().Be("Sean Rudford"); responseValue.User.IsVIP.Should().BeTrue(); responseValue.User.IsVIP_EP.Should().BeFalse(); responseValue.Sharing.Should().NotBeNull(); responseValue.Sharing.Facebook.Should().BeTrue(); responseValue.Sharing.Twitter.Should().BeTrue(); responseValue.Sharing.Tumblr.Should().BeFalse(); responseValue.Sharing.Medium.Should().BeTrue(); }
public void TestTraktSeasonCommentPostWriteJson() { var comment = "this is a comment"; var spoiler = false; var sharing = new TraktSharing { Facebook = true, Twitter = false, Tumblr = false }; var seasonTraktId = 16U; var season = new TraktSeason { Ids = new TraktSeasonIds { Trakt = seasonTraktId } }; var seasonComment = new TraktSeasonCommentPost { Comment = comment, Spoiler = spoiler, Sharing = sharing, Season = season }; var strJson = JsonConvert.SerializeObject(seasonComment); strJson.Should().NotBeNullOrEmpty(); var seasonCommentFromJson = JsonConvert.DeserializeObject <TraktSeasonCommentPost>(strJson); seasonCommentFromJson.Should().NotBeNull(); seasonCommentFromJson.Comment.Should().Be(comment); seasonCommentFromJson.Spoiler.Should().Be(spoiler); seasonCommentFromJson.Sharing.Should().NotBeNull(); seasonCommentFromJson.Sharing.Facebook.Should().BeTrue(); seasonCommentFromJson.Sharing.Twitter.Should().BeFalse(); seasonCommentFromJson.Sharing.Tumblr.Should().BeFalse(); seasonCommentFromJson.Season.Should().NotBeNull(); seasonCommentFromJson.Season.Ids.Should().NotBeNull(); seasonCommentFromJson.Season.Ids.Trakt.Should().Be(seasonTraktId); }