public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktCollectionShowEpisode obj, CancellationToken cancellationToken = default)
        {
            CheckJsonTextWriter(jsonWriter);
            await jsonWriter.WriteStartObjectAsync(cancellationToken).ConfigureAwait(false);

            if (obj.Number.HasValue)
            {
                await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_NUMBER, cancellationToken).ConfigureAwait(false);

                await jsonWriter.WriteValueAsync(obj.Number, cancellationToken).ConfigureAwait(false);
            }

            if (obj.CollectedAt.HasValue)
            {
                await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_COLLECTED_AT, cancellationToken).ConfigureAwait(false);

                await jsonWriter.WriteValueAsync(obj.CollectedAt.Value.ToTraktLongDateTimeString(), cancellationToken).ConfigureAwait(false);
            }

            if (obj.Metadata != null)
            {
                var metadataObjectJsonWriter = new MetadataObjectJsonWriter();
                await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_METADATA, cancellationToken).ConfigureAwait(false);

                await metadataObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Metadata, cancellationToken).ConfigureAwait(false);
            }

            await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false);
        }
        public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktCollectionMovie obj, CancellationToken cancellationToken = default)
        {
            if (jsonWriter == null)
            {
                throw new ArgumentNullException(nameof(jsonWriter));
            }

            await jsonWriter.WriteStartObjectAsync(cancellationToken).ConfigureAwait(false);

            if (obj.CollectedAt.HasValue)
            {
                await jsonWriter.WritePropertyNameAsync(JsonProperties.COLLECTION_MOVIE_PROPERTY_NAME_COLLECTED_AT, cancellationToken).ConfigureAwait(false);

                await jsonWriter.WriteValueAsync(obj.CollectedAt.Value.ToTraktLongDateTimeString(), cancellationToken).ConfigureAwait(false);
            }

            if (obj.Movie != null)
            {
                var movieObjectJsonWriter = new MovieObjectJsonWriter();
                await jsonWriter.WritePropertyNameAsync(JsonProperties.COLLECTION_MOVIE_PROPERTY_NAME_MOVIE, cancellationToken).ConfigureAwait(false);

                await movieObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Movie, cancellationToken).ConfigureAwait(false);
            }

            if (obj.Metadata != null)
            {
                var metadataObjectJsonWriter = new MetadataObjectJsonWriter();
                await jsonWriter.WritePropertyNameAsync(JsonProperties.COLLECTION_MOVIE_PROPERTY_NAME_METADATA, cancellationToken).ConfigureAwait(false);

                await metadataObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Metadata, cancellationToken).ConfigureAwait(false);
            }

            await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false);
        }
 public async Task Test_MetadataObjectJsonWriter_WriteObject_StringWriter_Exceptions()
 {
     var                   traktJsonWriter = new MetadataObjectJsonWriter();
     ITraktMetadata        traktMetadata   = new TraktMetadata();
     Func <Task <string> > action          = () => traktJsonWriter.WriteObjectAsync(default(StringWriter), traktMetadata);
     await action.Should().ThrowAsync <ArgumentNullException>();
 }
Exemple #4
0
        public void Test_MetadataObjectJsonWriter_WriteObject_Object_Exceptions()
        {
            var traktJsonWriter          = new MetadataObjectJsonWriter();
            Func <Task <string> > action = () => traktJsonWriter.WriteObjectAsync(default(ITraktMetadata));

            action.Should().Throw <ArgumentNullException>();
        }
        public void Test_MetadataObjectJsonWriter_WriteObject_JsonWriter_Exceptions()
        {
            var            traktJsonWriter = new MetadataObjectJsonWriter();
            ITraktMetadata traktMetadata   = new TraktMetadata();
            Func <Task>    action          = () => traktJsonWriter.WriteObjectAsync(default(JsonTextWriter), traktMetadata);

            action.Should().Throw <ArgumentNullException>();
        }
Exemple #6
0
        public async Task Test_MetadataObjectJsonWriter_WriteObject_Object_Only_MediaType_Property()
        {
            ITraktMetadata traktMetadata = new TraktMetadata
            {
                MediaType = TraktMediaType.Digital
            };

            var    traktJsonWriter = new MetadataObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(traktMetadata);

            json.Should().Be(@"{""media_type"":""digital""}");
        }
Exemple #7
0
        public async Task Test_MetadataObjectJsonWriter_WriteObject_Object_Only_MediaResolution_Property()
        {
            ITraktMetadata traktMetadata = new TraktMetadata
            {
                MediaResolution = TraktMediaResolution.UHD_4k
            };

            var    traktJsonWriter = new MetadataObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(traktMetadata);

            json.Should().Be(@"{""resolution"":""uhd_4k""}");
        }
Exemple #8
0
        public async Task Test_MetadataObjectJsonWriter_WriteObject_Object_Only_Audio_Property()
        {
            ITraktMetadata traktMetadata = new TraktMetadata
            {
                Audio = TraktMediaAudio.DolbyAtmos
            };

            var    traktJsonWriter = new MetadataObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(traktMetadata);

            json.Should().Be(@"{""audio"":""dolby_atmos""}");
        }
Exemple #9
0
        public async Task Test_MetadataObjectJsonWriter_WriteObject_Object_Only_AudioChannels_Property()
        {
            ITraktMetadata traktMetadata = new TraktMetadata
            {
                AudioChannels = TraktMediaAudioChannel.Channels_7_1
            };

            var    traktJsonWriter = new MetadataObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(traktMetadata);

            json.Should().Be(@"{""audio_channels"":""7.1""}");
        }
Exemple #10
0
        public async Task Test_MetadataObjectJsonWriter_WriteObject_Object_Only_ThreeDimensional_Property()
        {
            ITraktMetadata traktMetadata = new TraktMetadata
            {
                ThreeDimensional = true
            };

            var    traktJsonWriter = new MetadataObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(traktMetadata);

            json.Should().Be(@"{""3d"":true}");
        }
        public async Task Test_MetadataObjectJsonWriter_WriteObject_StringWriter_Only_HDR_Property()
        {
            ITraktMetadata traktMetadata = new TraktMetadata
            {
                HDR = TraktMediaHDR.DolbyVision
            };

            using (var stringWriter = new StringWriter())
            {
                var    traktJsonWriter = new MetadataObjectJsonWriter();
                string json            = await traktJsonWriter.WriteObjectAsync(stringWriter, traktMetadata);

                json.Should().Be(@"{""hdr"":""dolby_vision""}");
            }
        }
Exemple #12
0
        public async Task Test_MetadataObjectJsonWriter_WriteObject_JsonWriter_Only_AudioChannels_Property()
        {
            ITraktMetadata traktMetadata = new TraktMetadata
            {
                AudioChannels = TraktMediaAudioChannel.Channels_7_1
            };

            using (var stringWriter = new StringWriter())
                using (var jsonWriter = new JsonTextWriter(stringWriter))
                {
                    var traktJsonWriter = new MetadataObjectJsonWriter();
                    await traktJsonWriter.WriteObjectAsync(jsonWriter, traktMetadata);

                    stringWriter.ToString().Should().Be(@"{""audio_channels"":""7.1""}");
                }
        }
Exemple #13
0
        public async Task Test_MetadataObjectJsonWriter_WriteObject_JsonWriter_Only_Audio_Property()
        {
            ITraktMetadata traktMetadata = new TraktMetadata
            {
                Audio = TraktMediaAudio.DolbyAtmos
            };

            using (var stringWriter = new StringWriter())
                using (var jsonWriter = new JsonTextWriter(stringWriter))
                {
                    var traktJsonWriter = new MetadataObjectJsonWriter();
                    await traktJsonWriter.WriteObjectAsync(jsonWriter, traktMetadata);

                    stringWriter.ToString().Should().Be(@"{""audio"":""dolby_atmos""}");
                }
        }
Exemple #14
0
        public async Task Test_MetadataObjectJsonWriter_WriteObject_JsonWriter_Only_MediaResolution_Property()
        {
            ITraktMetadata traktMetadata = new TraktMetadata
            {
                MediaResolution = TraktMediaResolution.UHD_4k
            };

            using (var stringWriter = new StringWriter())
                using (var jsonWriter = new JsonTextWriter(stringWriter))
                {
                    var traktJsonWriter = new MetadataObjectJsonWriter();
                    await traktJsonWriter.WriteObjectAsync(jsonWriter, traktMetadata);

                    stringWriter.ToString().Should().Be(@"{""resolution"":""uhd_4k""}");
                }
        }
Exemple #15
0
        public async Task Test_MetadataObjectJsonWriter_WriteObject_JsonWriter_Only_MediaType_Property()
        {
            ITraktMetadata traktMetadata = new TraktMetadata
            {
                MediaType = TraktMediaType.Digital
            };

            using (var stringWriter = new StringWriter())
                using (var jsonWriter = new JsonTextWriter(stringWriter))
                {
                    var traktJsonWriter = new MetadataObjectJsonWriter();
                    await traktJsonWriter.WriteObjectAsync(jsonWriter, traktMetadata);

                    stringWriter.ToString().Should().Be(@"{""media_type"":""digital""}");
                }
        }
Exemple #16
0
        public async Task Test_MetadataObjectJsonWriter_WriteObject_JsonWriter_Only_ThreeDimensional_Property()
        {
            ITraktMetadata traktMetadata = new TraktMetadata
            {
                ThreeDimensional = true
            };

            using (var stringWriter = new StringWriter())
                using (var jsonWriter = new JsonTextWriter(stringWriter))
                {
                    var traktJsonWriter = new MetadataObjectJsonWriter();
                    await traktJsonWriter.WriteObjectAsync(jsonWriter, traktMetadata);

                    stringWriter.ToString().Should().Be(@"{""3d"":true}");
                }
        }
Exemple #17
0
        public async Task Test_MetadataObjectJsonWriter_WriteObject_Object_Complete()
        {
            ITraktMetadata traktMetadata = new TraktMetadata
            {
                MediaType        = TraktMediaType.Digital,
                MediaResolution  = TraktMediaResolution.UHD_4k,
                Audio            = TraktMediaAudio.DolbyAtmos,
                AudioChannels    = TraktMediaAudioChannel.Channels_7_1,
                ThreeDimensional = true
            };

            var    traktJsonWriter = new MetadataObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(traktMetadata);

            json.Should().Be(@"{""media_type"":""digital"",""resolution"":""uhd_4k"",""audio"":""dolby_atmos""," +
                             @"""audio_channels"":""7.1"",""3d"":true}");
        }
Exemple #18
0
        public async Task Test_MetadataObjectJsonWriter_WriteObject_JsonWriter_Complete()
        {
            ITraktMetadata traktMetadata = new TraktMetadata
            {
                MediaType        = TraktMediaType.Digital,
                MediaResolution  = TraktMediaResolution.UHD_4k,
                Audio            = TraktMediaAudio.DolbyAtmos,
                AudioChannels    = TraktMediaAudioChannel.Channels_7_1,
                HDR              = TraktMediaHDR.DolbyVision,
                ThreeDimensional = true
            };

            using (var stringWriter = new StringWriter())
                using (var jsonWriter = new JsonTextWriter(stringWriter))
                {
                    var traktJsonWriter = new MetadataObjectJsonWriter();
                    await traktJsonWriter.WriteObjectAsync(jsonWriter, traktMetadata);

                    stringWriter.ToString().Should().Be(@"{""media_type"":""digital"",""resolution"":""uhd_4k"",""audio"":""dolby_atmos""," +
                                                        @"""audio_channels"":""7.1"",""3d"":true,""hdr"":""dolby_vision""}");
                }
        }
 public void Test_MetadataObjectJsonWriter_WriteObject_Object_Exceptions()
 {
     var traktJsonWriter          = new MetadataObjectJsonWriter();
     Func <Task <string> > action = () => traktJsonWriter.WriteObjectAsync(default);