public void Test_EpisodeObjectJsonWriter_WriteObject_Object_Exceptions() { var traktJsonWriter = new EpisodeObjectJsonWriter(); Func <Task <string> > action = () => traktJsonWriter.WriteObjectAsync(default(ITraktEpisode)); action.Should().Throw <ArgumentNullException>(); }
public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktSyncPlaybackProgressItem obj, CancellationToken cancellationToken = default) { if (jsonWriter == null) { throw new ArgumentNullException(nameof(jsonWriter)); } await jsonWriter.WriteStartObjectAsync(cancellationToken).ConfigureAwait(false); await jsonWriter.WritePropertyNameAsync(JsonProperties.SYNC_PLAYBACK_PROGRESS_ITEM_PROPERTY_NAME_ID, cancellationToken).ConfigureAwait(false); await jsonWriter.WriteValueAsync(obj.Id, cancellationToken).ConfigureAwait(false); if (obj.Progress.HasValue) { await jsonWriter.WritePropertyNameAsync(JsonProperties.SYNC_PLAYBACK_PROGRESS_ITEM_PROPERTY_NAME_PROGRESS, cancellationToken).ConfigureAwait(false); await jsonWriter.WriteValueAsync(obj.Progress, cancellationToken).ConfigureAwait(false); } if (obj.PausedAt.HasValue) { await jsonWriter.WritePropertyNameAsync(JsonProperties.SYNC_PLAYBACK_PROGRESS_ITEM_PROPERTY_NAME_PAUSED_AT, cancellationToken).ConfigureAwait(false); await jsonWriter.WriteValueAsync(obj.PausedAt.Value.ToTraktLongDateTimeString(), cancellationToken).ConfigureAwait(false); } if (obj.Type != null) { await jsonWriter.WritePropertyNameAsync(JsonProperties.SYNC_PLAYBACK_PROGRESS_ITEM_PROPERTY_NAME_TYPE, cancellationToken).ConfigureAwait(false); await jsonWriter.WriteValueAsync(obj.Type.ObjectName, cancellationToken).ConfigureAwait(false); } if (obj.Movie != null) { var movieObjectJsonWriter = new MovieObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.SYNC_PLAYBACK_PROGRESS_ITEM_PROPERTY_NAME_MOVIE, cancellationToken).ConfigureAwait(false); await movieObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Movie, cancellationToken).ConfigureAwait(false); } if (obj.Episode != null) { var episodeObjectJsonWriter = new EpisodeObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.SYNC_PLAYBACK_PROGRESS_ITEM_PROPERTY_NAME_EPISODE, cancellationToken).ConfigureAwait(false); await episodeObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Episode, cancellationToken).ConfigureAwait(false); } if (obj.Show != null) { var showObjectJsonWriter = new ShowObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.SYNC_PLAYBACK_PROGRESS_ITEM_PROPERTY_NAME_SHOW, cancellationToken).ConfigureAwait(false); await showObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Show, cancellationToken).ConfigureAwait(false); } await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false); }
public async Task Test_EpisodeObjectJsonWriter_WriteObject_StringWriter_Exceptions() { var traktJsonWriter = new EpisodeObjectJsonWriter(); ITraktEpisode traktEpisode = new TraktEpisode(); Func <Task <string> > action = () => traktJsonWriter.WriteObjectAsync(default(StringWriter), traktEpisode); await action.Should().ThrowAsync <ArgumentNullException>(); }
public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktCalendarShow obj, CancellationToken cancellationToken = default) { if (jsonWriter == null) { throw new ArgumentNullException(nameof(jsonWriter)); } await jsonWriter.WriteStartObjectAsync(cancellationToken).ConfigureAwait(false); if (obj.FirstAiredInCalendar.HasValue) { await jsonWriter.WritePropertyNameAsync(JsonProperties.CALENDAR_SHOW_PROPERTY_NAME_FIRST_AIRED, cancellationToken).ConfigureAwait(false); await jsonWriter.WriteValueAsync(obj.FirstAiredInCalendar.Value.ToTraktLongDateTimeString(), cancellationToken).ConfigureAwait(false); } if (obj.Show != null) { var showObjectJsonWriter = new ShowObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.CALENDAR_SHOW_PROPERTY_NAME_SHOW, cancellationToken).ConfigureAwait(false); await showObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Show, cancellationToken).ConfigureAwait(false); } if (obj.Episode != null) { var episodeObjectJsonWriter = new EpisodeObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.CALENDAR_SHOW_PROPERTY_NAME_EPISODE, cancellationToken).ConfigureAwait(false); await episodeObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Episode, cancellationToken).ConfigureAwait(false); } await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false); }
public async Task Test_EpisodeObjectJsonWriter_WriteObject_StringWriter_Only_Translations_Property() { ITraktEpisode traktEpisode = new TraktEpisode { Translations = new List <TraktEpisodeTranslation> { new TraktEpisodeTranslation { Title = "german title", Overview = "german overview", LanguageCode = "de" }, new TraktEpisodeTranslation { Title = "english title", Overview = "english overview", LanguageCode = "en" } } }; using (var stringWriter = new StringWriter()) { var traktJsonWriter = new EpisodeObjectJsonWriter(); string json = await traktJsonWriter.WriteObjectAsync(stringWriter, traktEpisode); json.Should().Be(@"{""translations"":[{""title"":""german title"",""overview"":""german overview"",""language"":""de""}," + @"{""title"":""english title"",""overview"":""english overview"",""language"":""en""}]}"); } }
public async Task Test_EpisodeObjectJsonWriter_WriteObject_StringWriter_Complete() { ITraktEpisode traktEpisode = new TraktEpisode { SeasonNumber = 1, Number = 1, Title = "title", Ids = new TraktEpisodeIds { Trakt = 123456, Tvdb = 234567, Imdb = "345678", Tmdb = 456789, TvRage = 567890 }, NumberAbsolute = 1, Overview = "overview", Runtime = 60, Rating = 8.45672f, Votes = 8925, FirstAired = FIRST_AIRED, UpdatedAt = UPDATED_AT, AvailableTranslationLanguageCodes = new List <string> { "en", "de" }, Translations = new List <TraktEpisodeTranslation> { new TraktEpisodeTranslation { Title = "german title", Overview = "german overview", LanguageCode = "de" }, new TraktEpisodeTranslation { Title = "english title", Overview = "english overview", LanguageCode = "en" } } }; using (var stringWriter = new StringWriter()) { var traktJsonWriter = new EpisodeObjectJsonWriter(); string json = await traktJsonWriter.WriteObjectAsync(stringWriter, traktEpisode); json.Should().Be(@"{""season"":1,""number"":1,""title"":""title""," + @"""ids"":{""trakt"":123456,""tvdb"":234567,""imdb"":""345678"",""tmdb"":456789,""tvrage"":567890}," + @"""number_abs"":1,""overview"":""overview""," + @"""runtime"":60,""rating"":8.45672,""votes"":8925," + $"\"first_aired\":\"{FIRST_AIRED.ToTraktLongDateTimeString()}\"," + $"\"updated_at\":\"{UPDATED_AT.ToTraktLongDateTimeString()}\"," + @"""available_translations"":[""en"",""de""]," + @"""translations"":[{""title"":""german title"",""overview"":""german overview"",""language"":""de""}," + @"{""title"":""english title"",""overview"":""english overview"",""language"":""en""}]}"); } }
public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktRatingsItem obj, CancellationToken cancellationToken = default) { CheckJsonTextWriter(jsonWriter); await jsonWriter.WriteStartObjectAsync(cancellationToken).ConfigureAwait(false); if (obj.RatedAt.HasValue) { await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_RATED_AT, cancellationToken).ConfigureAwait(false); await jsonWriter.WriteValueAsync(obj.RatedAt.Value.ToTraktLongDateTimeString(), cancellationToken).ConfigureAwait(false); } if (obj.Rating.HasValue) { await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_RATING, cancellationToken).ConfigureAwait(false); await jsonWriter.WriteValueAsync(obj.Rating, cancellationToken).ConfigureAwait(false); } if (obj.Type != null) { await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_TYPE, cancellationToken).ConfigureAwait(false); await jsonWriter.WriteValueAsync(obj.Type.ObjectName, cancellationToken).ConfigureAwait(false); } if (obj.Movie != null) { var movieObjectJsonWriter = new MovieObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_MOVIE, cancellationToken).ConfigureAwait(false); await movieObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Movie, cancellationToken).ConfigureAwait(false); } if (obj.Show != null) { var showObjectJsonWriter = new ShowObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_SHOW, cancellationToken).ConfigureAwait(false); await showObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Show, cancellationToken).ConfigureAwait(false); } if (obj.Season != null) { var seasonObjectJsonWriter = new SeasonObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_SEASON, cancellationToken).ConfigureAwait(false); await seasonObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Season, cancellationToken).ConfigureAwait(false); } if (obj.Episode != null) { var episodeObjectJsonWriter = new EpisodeObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_EPISODE, cancellationToken).ConfigureAwait(false); await episodeObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Episode, cancellationToken).ConfigureAwait(false); } await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false); }
public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktShowCollectionProgress obj, CancellationToken cancellationToken = default) { CheckJsonTextWriter(jsonWriter); await jsonWriter.WriteStartObjectAsync(cancellationToken).ConfigureAwait(false); if (obj.Aired.HasValue) { await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_AIRED, cancellationToken).ConfigureAwait(false); await jsonWriter.WriteValueAsync(obj.Aired, cancellationToken).ConfigureAwait(false); } if (obj.Completed.HasValue) { await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_COMPLETED, cancellationToken).ConfigureAwait(false); await jsonWriter.WriteValueAsync(obj.Completed, cancellationToken).ConfigureAwait(false); } if (obj.LastCollectedAt.HasValue) { await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_LAST_COLLECTED_AT, cancellationToken).ConfigureAwait(false); await jsonWriter.WriteValueAsync(obj.LastCollectedAt.Value.ToTraktLongDateTimeString(), cancellationToken).ConfigureAwait(false); } if (obj.Seasons != null) { var seasonCollectionProgressArrayJsonWriter = new ArrayJsonWriter <ITraktSeasonCollectionProgress>(); await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_SEASONS, cancellationToken).ConfigureAwait(false); await seasonCollectionProgressArrayJsonWriter.WriteArrayAsync(jsonWriter, obj.Seasons, cancellationToken).ConfigureAwait(false); } if (obj.HiddenSeasons != null) { var seasonArrayJsonWriter = new ArrayJsonWriter <ITraktSeason>(); await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_HIDDEN_SEASONS, cancellationToken).ConfigureAwait(false); await seasonArrayJsonWriter.WriteArrayAsync(jsonWriter, obj.HiddenSeasons, cancellationToken).ConfigureAwait(false); } var episodeObjectJsonWriter = new EpisodeObjectJsonWriter(); if (obj.NextEpisode != null) { await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_NEXT_EPISODE, cancellationToken).ConfigureAwait(false); await episodeObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.NextEpisode, cancellationToken).ConfigureAwait(false); } if (obj.LastEpisode != null) { await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_LAST_EPISODE, cancellationToken).ConfigureAwait(false); await episodeObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.LastEpisode, cancellationToken).ConfigureAwait(false); } await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false); }
public void Test_EpisodeObjectJsonWriter_WriteObject_JsonWriter_Exceptions() { var traktJsonWriter = new EpisodeObjectJsonWriter(); ITraktEpisode traktEpisode = new TraktEpisode(); Func <Task> action = () => traktJsonWriter.WriteObjectAsync(default(JsonTextWriter), traktEpisode); action.Should().Throw <ArgumentNullException>(); }
public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktCommentItem obj, CancellationToken cancellationToken = default) { if (jsonWriter == null) { throw new ArgumentNullException(nameof(jsonWriter)); } await jsonWriter.WriteStartObjectAsync(cancellationToken).ConfigureAwait(false); if (obj.Type != null) { await jsonWriter.WritePropertyNameAsync(JsonProperties.COMMENT_ITEM_PROPERTY_NAME_TYPE, cancellationToken).ConfigureAwait(false); await jsonWriter.WriteValueAsync(obj.Type.ObjectName, cancellationToken).ConfigureAwait(false); } if (obj.Movie != null) { var movieObjectJsonWriter = new MovieObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.COMMENT_ITEM_PROPERTY_NAME_MOVIE, cancellationToken).ConfigureAwait(false); await movieObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Movie, cancellationToken).ConfigureAwait(false); } if (obj.Show != null) { var showObjectJsonWriter = new ShowObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.COMMENT_ITEM_PROPERTY_NAME_SHOW, cancellationToken).ConfigureAwait(false); await showObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Show, cancellationToken).ConfigureAwait(false); } if (obj.Season != null) { var seasonObjectJsonWriter = new SeasonObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.COMMENT_ITEM_PROPERTY_NAME_SEASON, cancellationToken).ConfigureAwait(false); await seasonObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Season, cancellationToken).ConfigureAwait(false); } if (obj.Episode != null) { var episodeObjectJsonWriter = new EpisodeObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.COMMENT_ITEM_PROPERTY_NAME_EPISODE, cancellationToken).ConfigureAwait(false); await episodeObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Episode, cancellationToken).ConfigureAwait(false); } if (obj.List != null) { var listObjectJsonWriter = new ListObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.COMMENT_ITEM_PROPERTY_NAME_LIST, cancellationToken).ConfigureAwait(false); await listObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.List, cancellationToken).ConfigureAwait(false); } await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false); }
public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktWatchlistItem obj, CancellationToken cancellationToken = default) { if (jsonWriter == null) { throw new ArgumentNullException(nameof(jsonWriter)); } await jsonWriter.WriteStartObjectAsync(cancellationToken).ConfigureAwait(false); if (obj.ListedAt.HasValue) { await jsonWriter.WritePropertyNameAsync(JsonProperties.COLLECTION_MOVIE_PROPERTY_NAME_COLLECTED_AT, cancellationToken).ConfigureAwait(false); await jsonWriter.WriteValueAsync(obj.ListedAt.Value.ToTraktLongDateTimeString(), cancellationToken).ConfigureAwait(false); } if (obj.Type != null) { await jsonWriter.WritePropertyNameAsync(JsonProperties.COLLECTION_MOVIE_PROPERTY_NAME_MOVIE, cancellationToken).ConfigureAwait(false); await jsonWriter.WriteValueAsync(obj.Type.ObjectName, cancellationToken).ConfigureAwait(false); } if (obj.Movie != null) { var movieObjectJsonWriter = new MovieObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.COLLECTION_MOVIE_PROPERTY_NAME_METADATA, cancellationToken).ConfigureAwait(false); await movieObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Movie, cancellationToken).ConfigureAwait(false); } if (obj.Show != null) { var showObjectJsonWriter = new ShowObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.COLLECTION_MOVIE_PROPERTY_NAME_METADATA, cancellationToken).ConfigureAwait(false); await showObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Show, cancellationToken).ConfigureAwait(false); } if (obj.Season != null) { var seasonObjectJsonWriter = new SeasonObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.COLLECTION_MOVIE_PROPERTY_NAME_METADATA, cancellationToken).ConfigureAwait(false); await seasonObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Season, cancellationToken).ConfigureAwait(false); } if (obj.Episode != null) { var episodeObjectJsonWriter = new EpisodeObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.COLLECTION_MOVIE_PROPERTY_NAME_METADATA, cancellationToken).ConfigureAwait(false); await episodeObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Episode, cancellationToken).ConfigureAwait(false); } await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false); }
protected override async Task WriteCommentObjectAsync(JsonTextWriter jsonWriter, ITraktEpisodeCommentPost obj, CancellationToken cancellationToken = default) { if (obj.Episode != null) { var episodeObjectJsonWriter = new EpisodeObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.EPISODE_COMMENT_POST_PROPERTY_NAME_EPISODE, cancellationToken).ConfigureAwait(false); await episodeObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Episode, cancellationToken).ConfigureAwait(false); } }
public async Task Test_EpisodeObjectJsonWriter_WriteObject_Object_Only_Rating_Property() { ITraktEpisode traktEpisode = new TraktEpisode { Rating = 8.45672f }; var traktJsonWriter = new EpisodeObjectJsonWriter(); string json = await traktJsonWriter.WriteObjectAsync(traktEpisode); json.Should().Be(@"{""rating"":8.45672}"); }
public async Task Test_EpisodeObjectJsonWriter_WriteObject_Object_Only_Runtime_Property() { ITraktEpisode traktEpisode = new TraktEpisode { Runtime = 60 }; var traktJsonWriter = new EpisodeObjectJsonWriter(); string json = await traktJsonWriter.WriteObjectAsync(traktEpisode); json.Should().Be(@"{""runtime"":60}"); }
public async Task Test_EpisodeObjectJsonWriter_WriteObject_Object_Only_SeasonNumber_Property() { ITraktEpisode traktEpisode = new TraktEpisode { SeasonNumber = 1 }; var traktJsonWriter = new EpisodeObjectJsonWriter(); string json = await traktJsonWriter.WriteObjectAsync(traktEpisode); json.Should().Be(@"{""season"":1}"); }
public async Task Test_EpisodeObjectJsonWriter_WriteObject_Object_Only_Votes_Property() { ITraktEpisode traktEpisode = new TraktEpisode { Votes = 8925 }; var traktJsonWriter = new EpisodeObjectJsonWriter(); string json = await traktJsonWriter.WriteObjectAsync(traktEpisode); json.Should().Be(@"{""votes"":8925}"); }
public async Task Test_EpisodeObjectJsonWriter_WriteObject_Object_Only_UpdatedAt_Property() { ITraktEpisode traktEpisode = new TraktEpisode { UpdatedAt = UPDATED_AT }; var traktJsonWriter = new EpisodeObjectJsonWriter(); string json = await traktJsonWriter.WriteObjectAsync(traktEpisode); json.Should().Be($"{{\"updated_at\":\"{UPDATED_AT.ToTraktLongDateTimeString()}\"}}"); }
public async Task Test_EpisodeObjectJsonWriter_WriteObject_Object_Only_FirstAired_Property() { ITraktEpisode traktEpisode = new TraktEpisode { FirstAired = FIRST_AIRED }; var traktJsonWriter = new EpisodeObjectJsonWriter(); string json = await traktJsonWriter.WriteObjectAsync(traktEpisode); json.Should().Be($"{{\"first_aired\":\"{FIRST_AIRED.ToTraktLongDateTimeString()}\"}}"); }
public async Task Test_EpisodeObjectJsonWriter_WriteObject_Object_Only_NumberAbsolute_Property() { ITraktEpisode traktEpisode = new TraktEpisode { NumberAbsolute = 1 }; var traktJsonWriter = new EpisodeObjectJsonWriter(); string json = await traktJsonWriter.WriteObjectAsync(traktEpisode); json.Should().Be(@"{""number_abs"":1}"); }
public async Task Test_EpisodeObjectJsonWriter_WriteObject_Object_Only_Title_Property() { ITraktEpisode traktEpisode = new TraktEpisode { Title = "title" }; var traktJsonWriter = new EpisodeObjectJsonWriter(); string json = await traktJsonWriter.WriteObjectAsync(traktEpisode); json.Should().Be(@"{""title"":""title""}"); }
public async Task Test_EpisodeObjectJsonWriter_WriteObject_Object_Only_Overview_Property() { ITraktEpisode traktEpisode = new TraktEpisode { Overview = "overview" }; var traktJsonWriter = new EpisodeObjectJsonWriter(); string json = await traktJsonWriter.WriteObjectAsync(traktEpisode); json.Should().Be(@"{""overview"":""overview""}"); }
public async Task Test_EpisodeObjectJsonWriter_WriteObject_StringWriter_Only_Number_Property() { ITraktEpisode traktEpisode = new TraktEpisode { Number = 1 }; using (var stringWriter = new StringWriter()) { var traktJsonWriter = new EpisodeObjectJsonWriter(); string json = await traktJsonWriter.WriteObjectAsync(stringWriter, traktEpisode); json.Should().Be(@"{""number"":1}"); } }
public async Task Test_EpisodeObjectJsonWriter_WriteObject_JsonWriter_Only_Title_Property() { ITraktEpisode traktEpisode = new TraktEpisode { Title = "title" }; using (var stringWriter = new StringWriter()) using (var jsonWriter = new JsonTextWriter(stringWriter)) { var traktJsonWriter = new EpisodeObjectJsonWriter(); await traktJsonWriter.WriteObjectAsync(jsonWriter, traktEpisode); stringWriter.ToString().Should().Be(@"{""title"":""title""}"); } }
public async Task Test_EpisodeObjectJsonWriter_WriteObject_JsonWriter_Only_SeasonNumber_Property() { ITraktEpisode traktEpisode = new TraktEpisode { SeasonNumber = 1 }; using (var stringWriter = new StringWriter()) using (var jsonWriter = new JsonTextWriter(stringWriter)) { var traktJsonWriter = new EpisodeObjectJsonWriter(); await traktJsonWriter.WriteObjectAsync(jsonWriter, traktEpisode); stringWriter.ToString().Should().Be(@"{""season"":1}"); } }
public async Task Test_EpisodeObjectJsonWriter_WriteObject_JsonWriter_Only_FirstAired_Property() { ITraktEpisode traktEpisode = new TraktEpisode { FirstAired = FIRST_AIRED }; using (var stringWriter = new StringWriter()) using (var jsonWriter = new JsonTextWriter(stringWriter)) { var traktJsonWriter = new EpisodeObjectJsonWriter(); await traktJsonWriter.WriteObjectAsync(jsonWriter, traktEpisode); stringWriter.ToString().Should().Be($"{{\"first_aired\":\"{FIRST_AIRED.ToTraktLongDateTimeString()}\"}}"); } }
public async Task Test_EpisodeObjectJsonWriter_WriteObject_JsonWriter_Only_Votes_Property() { ITraktEpisode traktEpisode = new TraktEpisode { Votes = 8925 }; using (var stringWriter = new StringWriter()) using (var jsonWriter = new JsonTextWriter(stringWriter)) { var traktJsonWriter = new EpisodeObjectJsonWriter(); await traktJsonWriter.WriteObjectAsync(jsonWriter, traktEpisode); stringWriter.ToString().Should().Be(@"{""votes"":8925}"); } }
public async Task Test_EpisodeObjectJsonWriter_WriteObject_JsonWriter_Only_Rating_Property() { ITraktEpisode traktEpisode = new TraktEpisode { Rating = 8.45672f }; using (var stringWriter = new StringWriter()) using (var jsonWriter = new JsonTextWriter(stringWriter)) { var traktJsonWriter = new EpisodeObjectJsonWriter(); await traktJsonWriter.WriteObjectAsync(jsonWriter, traktEpisode); stringWriter.ToString().Should().Be(@"{""rating"":8.45672}"); } }
public async Task Test_EpisodeObjectJsonWriter_WriteObject_JsonWriter_Only_UpdatedAt_Property() { ITraktEpisode traktEpisode = new TraktEpisode { UpdatedAt = UPDATED_AT }; using (var stringWriter = new StringWriter()) using (var jsonWriter = new JsonTextWriter(stringWriter)) { var traktJsonWriter = new EpisodeObjectJsonWriter(); await traktJsonWriter.WriteObjectAsync(jsonWriter, traktEpisode); stringWriter.ToString().Should().Be($"{{\"updated_at\":\"{UPDATED_AT.ToTraktLongDateTimeString()}\"}}"); } }
public async Task Test_EpisodeObjectJsonWriter_WriteObject_Object_Only_AvailableTranslationLanguageCodes_Property() { ITraktEpisode traktEpisode = new TraktEpisode { AvailableTranslationLanguageCodes = new List <string> { "en", "de" } }; var traktJsonWriter = new EpisodeObjectJsonWriter(); string json = await traktJsonWriter.WriteObjectAsync(traktEpisode); json.Should().Be(@"{""available_translations"":[""en"",""de""]}"); }
protected override async Task WriteScrobbleObjectAsync(JsonTextWriter jsonWriter, ITraktEpisodeScrobblePost obj, CancellationToken cancellationToken = default) { if (obj.Episode != null) { var episodeObjectJsonWriter = new EpisodeObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.EPISODE_SCROBBLE_POST_PROPERTY_NAME_EPISODE, cancellationToken).ConfigureAwait(false); await episodeObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Episode, cancellationToken).ConfigureAwait(false); } if (obj.Show != null) { var showObjectJsonWriter = new ShowObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.EPISODE_SCROBBLE_POST_PROPERTY_NAME_SHOW, cancellationToken).ConfigureAwait(false); await showObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Show, cancellationToken).ConfigureAwait(false); } }