コード例 #1
0
 public async Task Test_UserCustomListsReorderPostResponseObjectJsonWriter_WriteObject_JsonWriter_Exceptions()
 {
     var traktJsonWriter = new UserCustomListsReorderPostResponseObjectJsonWriter();
     ITraktUserCustomListsReorderPostResponse traktUserCustomListsReorderPostResponse = new TraktUserCustomListsReorderPostResponse();
     Func <Task> action = () => traktJsonWriter.WriteObjectAsync(default(JsonTextWriter), traktUserCustomListsReorderPostResponse);
     await action.Should().ThrowAsync <ArgumentNullException>();
 }
        public void Test_TraktUserCustomListsReorderPostResponse_Default_Constructor()
        {
            var userCustomListsReorderPostResponse = new TraktUserCustomListsReorderPostResponse();

            userCustomListsReorderPostResponse.Updated.Should().BeNull();
            userCustomListsReorderPostResponse.SkippedIds.Should().BeNull();
        }
コード例 #3
0
        public void Test_UserCustomListsReorderPostResponseObjectJsonWriter_WriteObject_StringWriter_Exceptions()
        {
            var traktJsonWriter = new UserCustomListsReorderPostResponseObjectJsonWriter();
            ITraktUserCustomListsReorderPostResponse traktUserCustomListsReorderPostResponse = new TraktUserCustomListsReorderPostResponse();
            Func <Task <string> > action = () => traktJsonWriter.WriteObjectAsync(default(StringWriter), traktUserCustomListsReorderPostResponse);

            action.Should().Throw <ArgumentNullException>();
        }
コード例 #4
0
        public async Task Test_UserCustomListsReorderPostResponseObjectJsonWriter_WriteObject_StringWriter_Only_Updated_Property()
        {
            ITraktUserCustomListsReorderPostResponse traktUserCustomListsReorderPostResponse = new TraktUserCustomListsReorderPostResponse
            {
                Updated = 6
            };

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

                json.Should().Be(@"{""updated"":6}");
            }
        }
コード例 #5
0
        public async Task Test_UserCustomListsReorderPostResponseObjectJsonWriter_WriteObject_StringWriter_Only_SkippedIds_Property()
        {
            ITraktUserCustomListsReorderPostResponse traktUserCustomListsReorderPostResponse = new TraktUserCustomListsReorderPostResponse
            {
                SkippedIds = new List <uint> {
                    2
                }
            };

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

                json.Should().Be(@"{""skipped_ids"":[2]}");
            }
        }
コード例 #6
0
        public async Task Test_UserCustomListsReorderPostResponseObjectJsonWriter_WriteObject_JsonWriter_Complete()
        {
            ITraktUserCustomListsReorderPostResponse traktUserCustomListsReorderPostResponse = new TraktUserCustomListsReorderPostResponse
            {
                Updated    = 6,
                SkippedIds = new List <uint> {
                    2
                }
            };

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

                    stringWriter.ToString().Should().Be(@"{""updated"":6,""skipped_ids"":[2]}");
                }
        }
コード例 #7
0
        public override async Task <ITraktUserCustomListsReorderPostResponse> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            CheckJsonTextReader(jsonReader);

            if (await jsonReader.ReadAsync(cancellationToken).ConfigureAwait(false) && jsonReader.TokenType == JsonToken.StartObject)
            {
                ITraktUserCustomListsReorderPostResponse userCustomListsReorderPostResponse = new TraktUserCustomListsReorderPostResponse();

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

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_UPDATED:
                        userCustomListsReorderPostResponse.Updated = await jsonReader.ReadAsInt32Async(cancellationToken).ConfigureAwait(false);

                        break;

                    case JsonProperties.PROPERTY_NAME_SKIPPED_IDS:
                        userCustomListsReorderPostResponse.SkippedIds = await JsonReaderHelper.ReadUnsignedIntegerArrayAsync(jsonReader, cancellationToken).ConfigureAwait(false);

                        break;

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

                        break;
                    }
                }

                return(userCustomListsReorderPostResponse);
            }

            return(await Task.FromResult(default(ITraktUserCustomListsReorderPostResponse)).ConfigureAwait(false));
        }