public async Task Test_EpisodeCollectionProgressArrayJsonReader_ReadArray_From_Stream_Not_Valid_4() { var traktJsonReader = new EpisodeCollectionProgressArrayJsonReader(); using (var stream = JSON_NOT_VALID_4.ToStream()) { var traktEpisodeCollectionProgresses = await traktJsonReader.ReadArrayAsync(stream); traktEpisodeCollectionProgresses.Should().NotBeNull().And.NotBeEmpty().And.HaveCount(3); var collectionProgress = traktEpisodeCollectionProgresses.ToArray(); collectionProgress[0].Number.Should().BeNull(); collectionProgress[0].Completed.Should().BeTrue(); collectionProgress[0].CollectedAt.Should().Be(DateTime.Parse("2011-04-18T01:00:00.000Z").ToUniversalTime()); collectionProgress[1].Number.Should().Be(2); collectionProgress[1].Completed.Should().BeNull(); collectionProgress[1].CollectedAt.Should().Be(DateTime.Parse("2011-04-18T01:00:00.000Z").ToUniversalTime()); collectionProgress[2].Number.Should().Be(3); collectionProgress[2].Completed.Should().BeTrue(); collectionProgress[2].CollectedAt.Should().BeNull(); } }
public async Task Test_EpisodeCollectionProgressArrayJsonReader_ReadArray_From_JsonReader_Incomplete_2() { var traktJsonReader = new EpisodeCollectionProgressArrayJsonReader(); using (var reader = new StringReader(JSON_INCOMPLETE_2)) using (var jsonReader = new JsonTextReader(reader)) { var traktEpisodeCollectionProgresses = await traktJsonReader.ReadArrayAsync(jsonReader); traktEpisodeCollectionProgresses.Should().NotBeNull().And.NotBeEmpty().And.HaveCount(3); var collectionProgress = traktEpisodeCollectionProgresses.ToArray(); collectionProgress[0].Number.Should().Be(1); collectionProgress[0].Completed.Should().BeTrue(); collectionProgress[0].CollectedAt.Should().Be(DateTime.Parse("2011-04-18T01:00:00.000Z").ToUniversalTime()); collectionProgress[1].Number.Should().Be(2); collectionProgress[1].Completed.Should().BeNull(); collectionProgress[1].CollectedAt.Should().Be(DateTime.Parse("2011-04-18T01:00:00.000Z").ToUniversalTime()); collectionProgress[2].Number.Should().Be(3); collectionProgress[2].Completed.Should().BeTrue(); collectionProgress[2].CollectedAt.Should().Be(DateTime.Parse("2011-04-18T01:00:00.000Z").ToUniversalTime()); } }
public async Task Test_EpisodeCollectionProgressArrayJsonReader_ReadArray_From_JsonReader_Null() { var traktJsonReader = new EpisodeCollectionProgressArrayJsonReader(); var traktEpisodeCollectionProgress = await traktJsonReader.ReadArrayAsync(default(JsonTextReader)); traktEpisodeCollectionProgress.Should().BeNull(); }
public async Task Test_EpisodeCollectionProgressArrayJsonReader_ReadArray_From_Json_String_Empty() { var jsonReader = new EpisodeCollectionProgressArrayJsonReader(); var traktEpisodeCollectionProgress = await jsonReader.ReadArrayAsync(string.Empty); traktEpisodeCollectionProgress.Should().BeNull(); }
public async Task Test_EpisodeCollectionProgressArrayJsonReader_ReadArray_From_Json_String_Empty_Array() { var jsonReader = new EpisodeCollectionProgressArrayJsonReader(); var traktEpisodeCollectionProgresses = await jsonReader.ReadArrayAsync(JSON_EMPTY_ARRAY); traktEpisodeCollectionProgresses.Should().NotBeNull().And.BeEmpty(); }
public async Task Test_EpisodeCollectionProgressArrayJsonReader_ReadArray_From_Stream_Empty() { var traktJsonReader = new EpisodeCollectionProgressArrayJsonReader(); using (var stream = string.Empty.ToStream()) { var traktEpisodeCollectionProgress = await traktJsonReader.ReadArrayAsync(stream); traktEpisodeCollectionProgress.Should().BeNull(); } }
public async Task Test_EpisodeCollectionProgressArrayJsonReader_ReadArray_From_Stream_Empty_Array() { var traktJsonReader = new EpisodeCollectionProgressArrayJsonReader(); using (var stream = JSON_EMPTY_ARRAY.ToStream()) { var traktEpisodeCollectionProgresses = await traktJsonReader.ReadArrayAsync(stream); traktEpisodeCollectionProgresses.Should().NotBeNull().And.BeEmpty(); } }
public async Task Test_EpisodeCollectionProgressArrayJsonReader_ReadArray_From_JsonReader_Empty() { var traktJsonReader = new EpisodeCollectionProgressArrayJsonReader(); using (var reader = new StringReader(string.Empty)) using (var jsonReader = new JsonTextReader(reader)) { var traktEpisodeCollectionProgress = await traktJsonReader.ReadArrayAsync(jsonReader); traktEpisodeCollectionProgress.Should().BeNull(); } }
public async Task Test_EpisodeCollectionProgressArrayJsonReader_ReadArray_From_JsonReader_Empty_Array() { var traktJsonReader = new EpisodeCollectionProgressArrayJsonReader(); using (var reader = new StringReader(JSON_EMPTY_ARRAY)) using (var jsonReader = new JsonTextReader(reader)) { var traktEpisodeCollectionProgresses = await traktJsonReader.ReadArrayAsync(jsonReader); traktEpisodeCollectionProgresses.Should().NotBeNull().And.BeEmpty(); } }
public override async Task <ITraktSeasonCollectionProgress> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { if (jsonReader == null) { return(await Task.FromResult(default(ITraktSeasonCollectionProgress))); } if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var episodeCollectionProgressArrayReader = new EpisodeCollectionProgressArrayJsonReader(); ITraktSeasonCollectionProgress traktSeasonCollectionProgress = new TraktSeasonCollectionProgress(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.SEASON_COLLECTION_PROGRESS_PROPERTY_NAME_NUMBER: traktSeasonCollectionProgress.Number = await jsonReader.ReadAsInt32Async(cancellationToken); break; case JsonProperties.SEASON_COLLECTION_PROGRESS_PROPERTY_NAME_AIRED: traktSeasonCollectionProgress.Aired = await jsonReader.ReadAsInt32Async(cancellationToken); break; case JsonProperties.SEASON_COLLECTION_PROGRESS_PROPERTY_NAME_COMPLETED: traktSeasonCollectionProgress.Completed = await jsonReader.ReadAsInt32Async(cancellationToken); break; case JsonProperties.SEASON_COLLECTION_PROGRESS_PROPERTY_NAME_EPISODES: traktSeasonCollectionProgress.Episodes = await episodeCollectionProgressArrayReader.ReadArrayAsync(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktSeasonCollectionProgress); } return(await Task.FromResult(default(ITraktSeasonCollectionProgress))); }