public async Task Test_PersonObjectJsonReader_ReadObject_From_JsonReader_Full_Not_Valid_7() { var traktJsonReader = new PersonObjectJsonReader(); using (var reader = new StringReader(FULL_JSON_NOT_VALID_7)) using (var jsonReader = new JsonTextReader(reader)) { var traktPerson = await traktJsonReader.ReadObjectAsync(jsonReader); traktPerson.Should().NotBeNull(); traktPerson.Name.Should().Be("Bryan Cranston"); traktPerson.Ids.Should().NotBeNull(); traktPerson.Ids.Trakt.Should().Be(297737U); traktPerson.Ids.Slug.Should().Be("bryan-cranston"); traktPerson.Ids.Imdb.Should().Be("nm0186505"); traktPerson.Ids.Tmdb.Should().Be(17419U); traktPerson.Ids.TvRage.Should().Be(1797U); traktPerson.Biography.Should().Be("Bryan Lee Cranston(born March 7, 1956) is an American actor, voice actor, writer and director.He is perhaps best known for his roles as Hal, the father in the Fox situation comedy Malcolm in the Middle, and as Walter White in the AMC drama series Breaking Bad, for which he has won three consecutive Outstanding Lead Actor in a Drama Series Emmy Awards. Other notable roles include Dr. Tim Whatley on Seinfeld, Doug Heffernan's neighbor in The King of Queens, Astronaut Buzz Aldrin in From the Earth to the Moon, and Ted Mosby's boss on How I Met Your Mother. Description above from the Wikipedia article Bryan Cranston, licensed under CC-BY-SA, full list of contributors on Wikipedia."); traktPerson.Birthday.Should().Be(DateTime.Parse("1956-03-07T00:00:00Z").ToUniversalTime()); traktPerson.Death.Should().Be(DateTime.Parse("2016-04-06T00:00:00Z").ToUniversalTime()); traktPerson.Age.Should().Be(60); traktPerson.Birthplace.Should().Be("San Fernando Valley, California, USA"); traktPerson.Homepage.Should().BeNull(); } }
public async Task Test_PersonObjectJsonReader_ReadObject_From_JsonReader_Minimal_Not_Valid_1() { var traktJsonReader = new PersonObjectJsonReader(); using (var reader = new StringReader(MINIMAL_JSON_NOT_VALID_1)) using (var jsonReader = new JsonTextReader(reader)) { var traktPerson = await traktJsonReader.ReadObjectAsync(jsonReader); traktPerson.Should().NotBeNull(); traktPerson.Name.Should().BeNull(); traktPerson.Ids.Should().NotBeNull(); traktPerson.Ids.Trakt.Should().Be(297737U); traktPerson.Ids.Slug.Should().Be("bryan-cranston"); traktPerson.Ids.Imdb.Should().Be("nm0186505"); traktPerson.Ids.Tmdb.Should().Be(17419U); traktPerson.Ids.TvRage.Should().Be(1797U); traktPerson.Biography.Should().BeNullOrEmpty(); traktPerson.Birthday.Should().NotHaveValue(); traktPerson.Death.Should().NotHaveValue(); traktPerson.Age.Should().Be(0); traktPerson.Birthplace.Should().BeNullOrEmpty(); traktPerson.Homepage.Should().BeNullOrEmpty(); } }
public void Test_PersonObjectJsonReader_ReadObject_From_JsonReader_Null() { var traktJsonReader = new PersonObjectJsonReader(); Func <Task <ITraktPerson> > traktPerson = () => traktJsonReader.ReadObjectAsync(default(JsonTextReader)); traktPerson.Should().Throw <ArgumentNullException>(); }
public async Task Test_PersonObjectJsonReader_ReadObject_From_JsonReader_Full_Not_Valid_3() { var traktJsonReader = new PersonObjectJsonReader(); using (var reader = new StringReader(FULL_JSON_NOT_VALID_3)) using (var jsonReader = new JsonTextReader(reader)) { var traktPerson = await traktJsonReader.ReadObjectAsync(jsonReader); traktPerson.Should().NotBeNull(); traktPerson.Name.Should().Be("Bryan Cranston"); traktPerson.Ids.Should().NotBeNull(); traktPerson.Ids.Trakt.Should().Be(297737U); traktPerson.Ids.Slug.Should().Be("bryan-cranston"); traktPerson.Ids.Imdb.Should().Be("nm0186505"); traktPerson.Ids.Tmdb.Should().Be(17419U); traktPerson.Ids.TvRage.Should().Be(1797U); traktPerson.Biography.Should().BeNull(); traktPerson.Birthday.Should().Be(DateTime.Parse("1956-03-07T00:00:00Z").ToUniversalTime()); traktPerson.Death.Should().Be(DateTime.Parse("2016-04-06T00:00:00Z").ToUniversalTime()); traktPerson.Age.Should().Be(60); traktPerson.Birthplace.Should().Be("San Fernando Valley, California, USA"); traktPerson.Homepage.Should().Be("http://www.bryancranston.com/"); } }
public async Task Test_PersonObjectJsonReader_ReadObject_From_JsonReader_Full_Incomplete_9() { var traktJsonReader = new PersonObjectJsonReader(); using (var reader = new StringReader(FULL_JSON_INCOMPLETE_9)) using (var jsonReader = new JsonTextReader(reader)) { var traktPerson = await traktJsonReader.ReadObjectAsync(jsonReader); traktPerson.Should().NotBeNull(); traktPerson.Name.Should().BeNull(); traktPerson.Ids.Should().NotBeNull(); traktPerson.Ids.Trakt.Should().Be(297737U); traktPerson.Ids.Slug.Should().Be("bryan-cranston"); traktPerson.Ids.Imdb.Should().Be("nm0186505"); traktPerson.Ids.Tmdb.Should().Be(17419U); traktPerson.Ids.TvRage.Should().Be(1797U); traktPerson.Biography.Should().BeNull(); traktPerson.Birthday.Should().BeNull(); traktPerson.Death.Should().BeNull(); traktPerson.Age.Should().Be(0); traktPerson.Birthplace.Should().BeNull(); traktPerson.Homepage.Should().BeNull(); } }
public async Task Test_PersonObjectJsonReader_ReadObject_From_Json_String_Empty() { var jsonReader = new PersonObjectJsonReader(); var traktPerson = await jsonReader.ReadObjectAsync(string.Empty); traktPerson.Should().BeNull(); }
public async Task Test_PersonObjectJsonReader_ReadObject_From_Stream_Null() { var traktJsonReader = new PersonObjectJsonReader(); var traktPerson = await traktJsonReader.ReadObjectAsync(default(Stream)); traktPerson.Should().BeNull(); }
public async Task Test_PersonObjectJsonReader_ReadObject_From_Stream_Empty() { var traktJsonReader = new PersonObjectJsonReader(); using (var stream = string.Empty.ToStream()) { var traktPerson = await traktJsonReader.ReadObjectAsync(stream); traktPerson.Should().BeNull(); } }
public async Task Test_PersonObjectJsonReader_ReadObject_From_JsonReader_Empty() { var traktJsonReader = new PersonObjectJsonReader(); using (var reader = new StringReader(string.Empty)) using (var jsonReader = new JsonTextReader(reader)) { var traktPerson = await traktJsonReader.ReadObjectAsync(jsonReader); traktPerson.Should().BeNull(); } }
public override async Task <ITraktShowCrewMember> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { CheckJsonTextReader(jsonReader); if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var personReader = new PersonObjectJsonReader(); ITraktShowCrewMember traktShowCrewMember = new TraktShowCrewMember(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.PROPERTY_NAME_JOBS: traktShowCrewMember.Jobs = await JsonReaderHelper.ReadStringArrayAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_EPISODE_COUNT: { var value = await JsonReaderHelper.ReadIntegerValueAsync(jsonReader, cancellationToken); if (value.First) { traktShowCrewMember.EpisodeCount = value.Second; } break; } case JsonProperties.PROPERTY_NAME_PERSON: traktShowCrewMember.Person = await personReader.ReadObjectAsync(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktShowCrewMember); } return(await Task.FromResult(default(ITraktShowCrewMember))); }
public async Task Test_PersonObjectJsonReader_ReadObject_From_Json_String_Full_Incomplete_14() { var jsonReader = new PersonObjectJsonReader(); var traktPerson = await jsonReader.ReadObjectAsync(FULL_JSON_INCOMPLETE_14); traktPerson.Should().NotBeNull(); traktPerson.Name.Should().BeNull(); traktPerson.Ids.Should().BeNull(); traktPerson.Biography.Should().BeNull(); traktPerson.Birthday.Should().BeNull(); traktPerson.Death.Should().BeNull(); traktPerson.Age.Should().Be(0); traktPerson.Birthplace.Should().BeNull(); traktPerson.Homepage.Should().Be("http://www.bryancranston.com/"); }
public async Task Test_PersonObjectJsonReader_ReadObject_From_Json_String_Full_Incomplete_13() { var jsonReader = new PersonObjectJsonReader(); var traktPerson = await jsonReader.ReadObjectAsync(FULL_JSON_INCOMPLETE_13); traktPerson.Should().NotBeNull(); traktPerson.Name.Should().BeNull(); traktPerson.Ids.Should().BeNull(); traktPerson.Biography.Should().BeNull(); traktPerson.Birthday.Should().BeNull(); traktPerson.Death.Should().BeNull(); traktPerson.Age.Should().Be(0); traktPerson.Birthplace.Should().Be("San Fernando Valley, California, USA"); traktPerson.Homepage.Should().BeNull(); }
public async Task Test_PersonObjectJsonReader_ReadObject_From_Json_String_Full_Incomplete_12() { var jsonReader = new PersonObjectJsonReader(); var traktPerson = await jsonReader.ReadObjectAsync(FULL_JSON_INCOMPLETE_12); traktPerson.Should().NotBeNull(); traktPerson.Name.Should().BeNull(); traktPerson.Ids.Should().BeNull(); traktPerson.Biography.Should().BeNull(); traktPerson.Birthday.Should().BeNull(); traktPerson.Death.Should().Be(DateTime.Parse("2016-04-06T00:00:00Z").ToUniversalTime()); traktPerson.Age.Should().Be(0); traktPerson.Birthplace.Should().BeNull(); traktPerson.Homepage.Should().BeNull(); }
public async Task Test_PersonObjectJsonReader_ReadObject_From_Json_String_Full_Incomplete_10() { var jsonReader = new PersonObjectJsonReader(); var traktPerson = await jsonReader.ReadObjectAsync(FULL_JSON_INCOMPLETE_10); traktPerson.Should().NotBeNull(); traktPerson.Name.Should().BeNull(); traktPerson.Ids.Should().BeNull(); traktPerson.Biography.Should().Be("Bryan Lee Cranston(born March 7, 1956) is an American actor, voice actor, writer and director.He is perhaps best known for his roles as Hal, the father in the Fox situation comedy Malcolm in the Middle, and as Walter White in the AMC drama series Breaking Bad, for which he has won three consecutive Outstanding Lead Actor in a Drama Series Emmy Awards. Other notable roles include Dr. Tim Whatley on Seinfeld, Doug Heffernan's neighbor in The King of Queens, Astronaut Buzz Aldrin in From the Earth to the Moon, and Ted Mosby's boss on How I Met Your Mother. Description above from the Wikipedia article Bryan Cranston, licensed under CC-BY-SA, full list of contributors on Wikipedia."); traktPerson.Birthday.Should().BeNull(); traktPerson.Death.Should().BeNull(); traktPerson.Age.Should().Be(0); traktPerson.Birthplace.Should().BeNull(); traktPerson.Homepage.Should().BeNull(); }
public async Task Test_PersonObjectJsonReader_ReadObject_From_Json_String_Minimal_Incomplete_1() { var jsonReader = new PersonObjectJsonReader(); var traktPerson = await jsonReader.ReadObjectAsync(MINIMAL_JSON_INCOMPLETE_1); traktPerson.Should().NotBeNull(); traktPerson.Name.Should().Be("Bryan Cranston"); traktPerson.Ids.Should().BeNull(); traktPerson.Biography.Should().BeNull(); traktPerson.Birthday.Should().BeNull(); traktPerson.Death.Should().BeNull(); traktPerson.Age.Should().Be(0); traktPerson.Birthplace.Should().BeNull(); traktPerson.Homepage.Should().BeNull(); }
public async Task Test_PersonObjectJsonReader_ReadObject_From_Json_String_Full_Not_Valid_8() { var jsonReader = new PersonObjectJsonReader(); var traktPerson = await jsonReader.ReadObjectAsync(FULL_JSON_NOT_VALID_8); traktPerson.Should().NotBeNull(); traktPerson.Name.Should().BeNull(); traktPerson.Ids.Should().BeNull(); traktPerson.Biography.Should().BeNull(); traktPerson.Birthday.Should().BeNull(); traktPerson.Death.Should().BeNull(); traktPerson.Age.Should().Be(0); traktPerson.Birthplace.Should().BeNull(); traktPerson.Homepage.Should().BeNull(); }
public async Task Test_PersonObjectJsonReader_ReadObject_From_Stream_Full_Incomplete_11() { var traktJsonReader = new PersonObjectJsonReader(); using (var stream = FULL_JSON_INCOMPLETE_11.ToStream()) { var traktPerson = await traktJsonReader.ReadObjectAsync(stream); traktPerson.Should().NotBeNull(); traktPerson.Name.Should().BeNull(); traktPerson.Ids.Should().BeNull(); traktPerson.Biography.Should().BeNull(); traktPerson.Birthday.Should().Be(DateTime.Parse("1956-03-07T00:00:00Z").ToUniversalTime()); traktPerson.Death.Should().BeNull(); traktPerson.Age.Should().Be(traktPerson.Birthday.YearsBetween(DateTime.Now)); traktPerson.Birthplace.Should().BeNull(); traktPerson.Homepage.Should().BeNull(); } }
public async Task Test_PersonObjectJsonReader_ReadObject_From_Stream_Full_Not_Valid_8() { var traktJsonReader = new PersonObjectJsonReader(); using (var stream = FULL_JSON_NOT_VALID_8.ToStream()) { var traktPerson = await traktJsonReader.ReadObjectAsync(stream); traktPerson.Should().NotBeNull(); traktPerson.Name.Should().BeNull(); traktPerson.Ids.Should().BeNull(); traktPerson.Biography.Should().BeNull(); traktPerson.Birthday.Should().BeNull(); traktPerson.Death.Should().BeNull(); traktPerson.Age.Should().Be(0); traktPerson.Birthplace.Should().BeNull(); traktPerson.Homepage.Should().BeNull(); } }
public async Task Test_PersonObjectJsonReader_ReadObject_From_Stream_Minimal_Incomplete_1() { var traktJsonReader = new PersonObjectJsonReader(); using (var stream = MINIMAL_JSON_INCOMPLETE_1.ToStream()) { var traktPerson = await traktJsonReader.ReadObjectAsync(stream); traktPerson.Should().NotBeNull(); traktPerson.Name.Should().Be("Bryan Cranston"); traktPerson.Ids.Should().BeNull(); traktPerson.Biography.Should().BeNullOrEmpty(); traktPerson.Birthday.Should().NotHaveValue(); traktPerson.Death.Should().NotHaveValue(); traktPerson.Age.Should().Be(0); traktPerson.Birthplace.Should().BeNullOrEmpty(); traktPerson.Homepage.Should().BeNullOrEmpty(); } }
public async Task Test_PersonObjectJsonReader_ReadObject_From_JsonReader_Full_Incomplete_8() { var traktJsonReader = new PersonObjectJsonReader(); using (var reader = new StringReader(FULL_JSON_INCOMPLETE_8)) using (var jsonReader = new JsonTextReader(reader)) { var traktPerson = await traktJsonReader.ReadObjectAsync(jsonReader); traktPerson.Should().NotBeNull(); traktPerson.Name.Should().Be("Bryan Cranston"); traktPerson.Ids.Should().BeNull(); traktPerson.Biography.Should().BeNull(); traktPerson.Birthday.Should().BeNull(); traktPerson.Death.Should().BeNull(); traktPerson.Age.Should().Be(0); traktPerson.Birthplace.Should().BeNull(); traktPerson.Homepage.Should().BeNull(); } }
public async Task Test_PersonObjectJsonReader_ReadObject_From_JsonReader_Minimal_Not_Valid_3() { var traktJsonReader = new PersonObjectJsonReader(); using (var reader = new StringReader(MINIMAL_JSON_NOT_VALID_3)) using (var jsonReader = new JsonTextReader(reader)) { var traktPerson = await traktJsonReader.ReadObjectAsync(jsonReader); traktPerson.Should().NotBeNull(); traktPerson.Name.Should().BeNull(); traktPerson.Ids.Should().BeNull(); traktPerson.Biography.Should().BeNullOrEmpty(); traktPerson.Birthday.Should().NotHaveValue(); traktPerson.Death.Should().NotHaveValue(); traktPerson.Age.Should().Be(0); traktPerson.Birthplace.Should().BeNullOrEmpty(); traktPerson.Homepage.Should().BeNullOrEmpty(); } }
public async Task Test_TraktPerson_From_Minimal_Json() { var jsonReader = new PersonObjectJsonReader(); var person = await jsonReader.ReadObjectAsync(MINIMAL_JSON) as TraktPerson; person.Should().NotBeNull(); person.Name.Should().Be("Bryan Cranston"); person.Ids.Should().NotBeNull(); person.Ids.Trakt.Should().Be(297737U); person.Ids.Slug.Should().Be("bryan-cranston"); person.Ids.Imdb.Should().Be("nm0186505"); person.Ids.Tmdb.Should().Be(17419U); person.Ids.TvRage.Should().Be(1797U); person.Biography.Should().BeNullOrEmpty(); person.Birthday.Should().NotHaveValue(); person.Death.Should().NotHaveValue(); person.Age.Should().Be(0); person.Birthplace.Should().BeNullOrEmpty(); person.Homepage.Should().BeNullOrEmpty(); }
public async Task Test_PersonObjectJsonReader_ReadObject_From_Json_String_Minimal_Incomplete_2() { var jsonReader = new PersonObjectJsonReader(); var traktPerson = await jsonReader.ReadObjectAsync(MINIMAL_JSON_INCOMPLETE_2); traktPerson.Should().NotBeNull(); traktPerson.Name.Should().BeNull(); traktPerson.Ids.Should().NotBeNull(); traktPerson.Ids.Trakt.Should().Be(297737U); traktPerson.Ids.Slug.Should().Be("bryan-cranston"); traktPerson.Ids.Imdb.Should().Be("nm0186505"); traktPerson.Ids.Tmdb.Should().Be(17419U); traktPerson.Ids.TvRage.Should().Be(1797U); traktPerson.Biography.Should().BeNull(); traktPerson.Birthday.Should().BeNull(); traktPerson.Death.Should().BeNull(); traktPerson.Age.Should().Be(0); traktPerson.Birthplace.Should().BeNull(); traktPerson.Homepage.Should().BeNull(); }
public override async Task <ITraktCrewMember> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { if (jsonReader == null) { return(await Task.FromResult(default(ITraktCrewMember))); } if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var personReader = new PersonObjectJsonReader(); ITraktCrewMember traktCrewMember = new TraktCrewMember(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.CREW_MEMBER_PROPERTY_NAME_JOB: traktCrewMember.Job = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.CREW_MEMBER_PROPERTY_NAME_PERSON: traktCrewMember.Person = await personReader.ReadObjectAsync(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktCrewMember); } return(await Task.FromResult(default(ITraktCrewMember))); }
public override async Task <ITraktCastMember> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { CheckJsonTextReader(jsonReader); if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var personReader = new PersonObjectJsonReader(); ITraktCastMember traktCastMember = new TraktCastMember(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.PROPERTY_NAME_CHARACTERS: traktCastMember.Characters = await JsonReaderHelper.ReadStringArrayAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_PERSON: traktCastMember.Person = await personReader.ReadObjectAsync(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktCastMember); } return(await Task.FromResult(default(ITraktCastMember))); }
public async Task Test_PersonObjectJsonReader_ReadObject_From_Stream_Full_Incomplete_3() { var traktJsonReader = new PersonObjectJsonReader(); using (var stream = FULL_JSON_INCOMPLETE_3.ToStream()) { var traktPerson = await traktJsonReader.ReadObjectAsync(stream); traktPerson.Should().NotBeNull(); traktPerson.Name.Should().Be("Bryan Cranston"); traktPerson.Ids.Should().NotBeNull(); traktPerson.Ids.Trakt.Should().Be(297737U); traktPerson.Ids.Slug.Should().Be("bryan-cranston"); traktPerson.Ids.Imdb.Should().Be("nm0186505"); traktPerson.Ids.Tmdb.Should().Be(17419U); traktPerson.Ids.TvRage.Should().Be(1797U); traktPerson.Biography.Should().BeNull(); traktPerson.Birthday.Should().Be(DateTime.Parse("1956-03-07T00:00:00Z").ToUniversalTime()); traktPerson.Death.Should().Be(DateTime.Parse("2016-04-06T00:00:00Z").ToUniversalTime()); traktPerson.Age.Should().Be(60); traktPerson.Birthplace.Should().Be("San Fernando Valley, California, USA"); traktPerson.Homepage.Should().Be("http://www.bryancranston.com/"); } }
public async Task Test_PersonObjectJsonReader_ReadObject_From_Stream_Minimal_Incomplete_2() { var traktJsonReader = new PersonObjectJsonReader(); using (var stream = MINIMAL_JSON_INCOMPLETE_2.ToStream()) { var traktPerson = await traktJsonReader.ReadObjectAsync(stream); traktPerson.Should().NotBeNull(); traktPerson.Name.Should().BeNull(); traktPerson.Ids.Should().NotBeNull(); traktPerson.Ids.Trakt.Should().Be(297737U); traktPerson.Ids.Slug.Should().Be("bryan-cranston"); traktPerson.Ids.Imdb.Should().Be("nm0186505"); traktPerson.Ids.Tmdb.Should().Be(17419U); traktPerson.Ids.TvRage.Should().Be(1797U); traktPerson.Biography.Should().BeNullOrEmpty(); traktPerson.Birthday.Should().NotHaveValue(); traktPerson.Death.Should().NotHaveValue(); traktPerson.Age.Should().Be(0); traktPerson.Birthplace.Should().BeNullOrEmpty(); traktPerson.Homepage.Should().BeNullOrEmpty(); } }
public override async Task <ITraktSearchResult> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { CheckJsonTextReader(jsonReader); if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var movieObjectReader = new MovieObjectJsonReader(); var showObjectReader = new ShowObjectJsonReader(); var episodeObjectReader = new EpisodeObjectJsonReader(); var personObjectReader = new PersonObjectJsonReader(); var listObjectReader = new ListObjectJsonReader(); ITraktSearchResult traktSearchResult = new TraktSearchResult(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.PROPERTY_NAME_TYPE: traktSearchResult.Type = await JsonReaderHelper.ReadEnumerationValueAsync <TraktSearchResultType>(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_SCORE: { var value = await JsonReaderHelper.ReadFloatValueAsync(jsonReader, cancellationToken); if (value.First) { traktSearchResult.Score = value.Second; } break; } case JsonProperties.PROPERTY_NAME_MOVIE: traktSearchResult.Movie = await movieObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_SHOW: traktSearchResult.Show = await showObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_EPISODE: traktSearchResult.Episode = await episodeObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_PERSON: traktSearchResult.Person = await personObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_LIST: traktSearchResult.List = await listObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktSearchResult); } return(await Task.FromResult(default(ITraktSearchResult))); }
public override async Task<ITraktListItem> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { CheckJsonTextReader(jsonReader); if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var movieReader = new MovieObjectJsonReader(); var showReader = new ShowObjectJsonReader(); var seasonReader = new SeasonObjectJsonReader(); var episodeReader = new EpisodeObjectJsonReader(); var personReader = new PersonObjectJsonReader(); ITraktListItem traktListItem = new TraktListItem(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.PROPERTY_NAME_ID: { var value = await JsonReaderHelper.ReadUnsignedIntegerValueAsync(jsonReader, cancellationToken); if (value.First) traktListItem.Id = value.Second; break; } case JsonProperties.PROPERTY_NAME_RANK: traktListItem.Rank = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.PROPERTY_NAME_LISTED_AT: { var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken); if (value.First) traktListItem.ListedAt = value.Second; break; } case JsonProperties.PROPERTY_NAME_TYPE: traktListItem.Type = await JsonReaderHelper.ReadEnumerationValueAsync<TraktListItemType>(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_MOVIE: traktListItem.Movie = await movieReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_SHOW: traktListItem.Show = await showReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_SEASON: traktListItem.Season = await seasonReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_EPISODE: traktListItem.Episode = await episodeReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_PERSON: traktListItem.Person = await personReader.ReadObjectAsync(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return traktListItem; } return await Task.FromResult(default(ITraktListItem)); }
public async Task Test_PersonObjectJsonReader_ReadObject_From_Stream_Null() { var traktJsonReader = new PersonObjectJsonReader(); Func <Task <ITraktPerson> > traktPerson = () => traktJsonReader.ReadObjectAsync(default(Stream)); await traktPerson.Should().ThrowAsync <ArgumentNullException>(); }