public async Task Test_CollectionShowSeasonObjectJsonWriter_WriteObject_StringWriter_Exceptions() { var traktJsonWriter = new CollectionShowSeasonObjectJsonWriter(); ITraktCollectionShowSeason traktCollectionShowSeason = new TraktCollectionShowSeason(); Func <Task <string> > action = () => traktJsonWriter.WriteObjectAsync(default(StringWriter), traktCollectionShowSeason); await action.Should().ThrowAsync <ArgumentNullException>(); }
public void Test_TraktCollectionShowSeason_Default_Constructor() { var collectionShowEpisode = new TraktCollectionShowSeason(); collectionShowEpisode.Number.Should().BeNull(); collectionShowEpisode.Episodes.Should().BeNull(); }
public void Test_CollectionShowSeasonObjectJsonWriter_WriteObject_JsonWriter_Exceptions() { var traktJsonWriter = new CollectionShowSeasonObjectJsonWriter(); ITraktCollectionShowSeason traktCollectionShowSeason = new TraktCollectionShowSeason(); Func <Task> action = () => traktJsonWriter.WriteObjectAsync(default(JsonTextWriter), traktCollectionShowSeason); action.Should().Throw <ArgumentNullException>(); }
public async Task Test_CollectionShowSeasonObjectJsonWriter_WriteObject_JsonWriter_Complete() { ITraktCollectionShowSeason traktCollectionShowSeason = new TraktCollectionShowSeason { Number = 1, Episodes = new List <ITraktCollectionShowEpisode> { new TraktCollectionShowEpisode { Number = 1, CollectedAt = COLLECTED_AT, Metadata = new TraktMetadata { MediaType = TraktMediaType.Digital, MediaResolution = TraktMediaResolution.HD_720p, Audio = TraktMediaAudio.AAC, AudioChannels = TraktMediaAudioChannel.Channels_5_1, ThreeDimensional = true } }, new TraktCollectionShowEpisode { Number = 1, CollectedAt = COLLECTED_AT, Metadata = new TraktMetadata { MediaType = TraktMediaType.Digital, MediaResolution = TraktMediaResolution.HD_720p, Audio = TraktMediaAudio.AAC, AudioChannels = TraktMediaAudioChannel.Channels_5_1, ThreeDimensional = true } } } }; using (var stringWriter = new StringWriter()) using (var jsonWriter = new JsonTextWriter(stringWriter)) { var traktJsonWriter = new CollectionShowSeasonObjectJsonWriter(); await traktJsonWriter.WriteObjectAsync(jsonWriter, traktCollectionShowSeason); stringWriter.ToString().Should().Be(@"{""number"":1,""episodes"":[{""number"":1," + $"\"collected_at\":\"{COLLECTED_AT.ToTraktLongDateTimeString()}\"," + @"""metadata"":{""media_type"":""digital""," + @"""resolution"":""hd_720p"",""audio"":""aac""," + @"""audio_channels"":""5.1"",""3d"":true}}," + @"{""number"":1," + $"\"collected_at\":\"{COLLECTED_AT.ToTraktLongDateTimeString()}\"," + @"""metadata"":{""media_type"":""digital""," + @"""resolution"":""hd_720p"",""audio"":""aac""," + @"""audio_channels"":""5.1"",""3d"":true}}]}"); } }
public async Task Test_CollectionShowSeasonObjectJsonWriter_WriteObject_StringWriter_Only_Number_Property() { ITraktCollectionShowSeason traktCollectionShowSeason = new TraktCollectionShowSeason { Number = 1 }; using (var stringWriter = new StringWriter()) { var traktJsonWriter = new CollectionShowSeasonObjectJsonWriter(); string json = await traktJsonWriter.WriteObjectAsync(stringWriter, traktCollectionShowSeason); json.Should().Be(@"{""number"":1}"); } }
public override async Task <ITraktCollectionShowSeason> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { if (jsonReader == null) { return(await Task.FromResult(default(ITraktCollectionShowSeason))); } if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var collectionShowEpisodeArrayReader = new CollectionShowEpisodeArrayJsonReader(); ITraktCollectionShowSeason traktCollectionShowSeason = new TraktCollectionShowSeason(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.COLLECTION_SHOW_SEASON_PROPERTY_NAME_NUMBER: traktCollectionShowSeason.Number = await jsonReader.ReadAsInt32Async(cancellationToken); break; case JsonProperties.COLLECTION_SHOW_SEASON_PROPERTY_NAME_EPISODES: traktCollectionShowSeason.Episodes = await collectionShowEpisodeArrayReader.ReadArrayAsync(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktCollectionShowSeason); } return(await Task.FromResult(default(ITraktCollectionShowSeason))); }