Example #1
0
        public void TestTraktMovieCheckinPostResponseDefaultConstructor()
        {
            var movieCheckinResponse = new TraktMovieCheckinPostResponse();

            movieCheckinResponse.WatchedAt.Should().NotHaveValue();
            movieCheckinResponse.Sharing.Should().BeNull();
            movieCheckinResponse.Movie.Should().BeNull();
        }
Example #2
0
        public void Test_TraktMovieCheckinPostResponse_Default_Constructor()
        {
            var movieCheckinResponse = new TraktMovieCheckinPostResponse();

            movieCheckinResponse.Id.Should().Be(0);
            movieCheckinResponse.WatchedAt.Should().BeNull();
            movieCheckinResponse.Sharing.Should().BeNull();
            movieCheckinResponse.Movie.Should().BeNull();
        }
        public override async Task <ITraktMovieCheckinPostResponse> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktMovieCheckinPostResponse)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var sharingReader = new SharingObjectJsonReader();
                var movieReader   = new MovieObjectJsonReader();
                ITraktMovieCheckinPostResponse checkinMovieResponse = new TraktMovieCheckinPostResponse();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.CHECKIN_POST_RESPONSE_PROPERTY_NAME_ID:
                    {
                        var value = await JsonReaderHelper.ReadUnsignedLongIntegerAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            checkinMovieResponse.Id = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.CHECKIN_POST_RESPONSE_PROPERTY_NAME_WATCHED_AT:
                    {
                        var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            checkinMovieResponse.WatchedAt = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.CHECKIN_POST_RESPONSE_PROPERTY_NAME_SHARING:
                        checkinMovieResponse.Sharing = await sharingReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.MOVIE_CHECKIN_POST_RESPONSE_PROPERTY_NAME_MOVIE:
                        checkinMovieResponse.Movie = await movieReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(checkinMovieResponse);
            }

            return(await Task.FromResult(default(ITraktMovieCheckinPostResponse)));
        }