public void Test_TraktRatingsItem_Default_Constructor() { var ratingsItem = new TraktRatingsItem(); ratingsItem.Rating.Should().NotHaveValue(); ratingsItem.RatedAt.Should().NotHaveValue(); ratingsItem.Type.Should().BeNull(); ratingsItem.Movie.Should().BeNull(); ratingsItem.Show.Should().BeNull(); ratingsItem.Season.Should().BeNull(); ratingsItem.Episode.Should().BeNull(); }
public override async Task <ITraktRatingsItem> 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 seasonObjectReader = new SeasonObjectJsonReader(); var episodeObjectReader = new EpisodeObjectJsonReader(); ITraktRatingsItem traktRatingItem = new TraktRatingsItem(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.PROPERTY_NAME_RATED_AT: { var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken); if (value.First) { traktRatingItem.RatedAt = value.Second; } break; } case JsonProperties.PROPERTY_NAME_RATING: traktRatingItem.Rating = await jsonReader.ReadAsInt32Async(cancellationToken); break; case JsonProperties.PROPERTY_NAME_TYPE: traktRatingItem.Type = await JsonReaderHelper.ReadEnumerationValueAsync <TraktRatingsItemType>(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_MOVIE: traktRatingItem.Movie = await movieObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_SHOW: traktRatingItem.Show = await showObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_SEASON: traktRatingItem.Season = await seasonObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_EPISODE: traktRatingItem.Episode = await episodeObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktRatingItem); } return(await Task.FromResult(default(ITraktRatingsItem))); }