Ejemplo n.º 1
0
 public async Task Test_UserCustomListsReorderPostObjectJsonWriter_WriteObject_StringWriter_Exceptions()
 {
     var traktJsonWriter = new UserCustomListsReorderPostObjectJsonWriter();
     ITraktUserCustomListsReorderPost traktUserCustomListsReorderPost = new TraktUserCustomListsReorderPost();
     Func <Task <string> >            action = () => traktJsonWriter.WriteObjectAsync(default(StringWriter), traktUserCustomListsReorderPost);
     await action.Should().ThrowAsync <ArgumentNullException>();
 }
Ejemplo n.º 2
0
        public async Task Test_TraktUsersModule_ReorderCustomListItems_ArgumentExceptions()
        {
            ITraktUserCustomListsReorderPost customListItemsReorderPost = new TraktUserCustomListsReorderPost
            {
                Rank = REORDERED_CUSTOM_LIST_ITEMS
            };

            string postJson = await TestUtility.SerializeObject(customListItemsReorderPost);

            postJson.Should().NotBeNullOrEmpty();

            TraktClient client = TestUtility.GetOAuthMockClient(REORDER_CUSTOM_LIST_ITEMS_URI, postJson, CUSTOM_LIST_ITEMS_REORDER_POST_RESPONSE_JSON);

            Func <Task <TraktResponse <ITraktUserCustomListsReorderPostResponse> > > act = () => client.Users.ReorderCustomListItemsAsync(null, LIST_ID, REORDERED_CUSTOM_LIST_ITEMS);

            act.Should().Throw <ArgumentNullException>();

            act = () => client.Users.ReorderCustomListItemsAsync(string.Empty, LIST_ID, REORDERED_CUSTOM_LIST_ITEMS);
            act.Should().Throw <ArgumentException>();

            act = () => client.Users.ReorderCustomListItemsAsync("user name", LIST_ID, REORDERED_CUSTOM_LIST_ITEMS);
            act.Should().Throw <ArgumentException>();

            act = () => client.Users.ReorderCustomListItemsAsync("username", null, REORDERED_CUSTOM_LIST_ITEMS);
            act.Should().Throw <ArgumentNullException>();

            act = () => client.Users.ReorderCustomListItemsAsync("username", string.Empty, REORDERED_CUSTOM_LIST_ITEMS);
            act.Should().Throw <ArgumentException>();

            act = () => client.Users.ReorderCustomListItemsAsync("username", "list id", REORDERED_CUSTOM_LIST_ITEMS);
            act.Should().Throw <ArgumentException>();

            act = () => client.Users.ReorderCustomListItemsAsync(USERNAME, LIST_ID, null);
            act.Should().Throw <ArgumentNullException>();
        }
Ejemplo n.º 3
0
        public async Task Test_TraktUsersModule_ReorderCustomListItems()
        {
            ITraktUserCustomListsReorderPost customListItemsReorderPost = new TraktUserCustomListsReorderPost
            {
                Rank = REORDERED_CUSTOM_LIST_ITEMS
            };

            string postJson = await TestUtility.SerializeObject(customListItemsReorderPost);

            postJson.Should().NotBeNullOrEmpty();

            TraktClient client = TestUtility.GetOAuthMockClient(REORDER_CUSTOM_LIST_ITEMS_URI, postJson, CUSTOM_LIST_ITEMS_REORDER_POST_RESPONSE_JSON);
            TraktResponse <ITraktUserCustomListsReorderPostResponse> response = await client.Users.ReorderCustomListItemsAsync(USERNAME, LIST_ID, REORDERED_CUSTOM_LIST_ITEMS);

            response.Should().NotBeNull();
            response.IsSuccess.Should().BeTrue();
            response.HasValue.Should().BeTrue();
            response.Value.Should().NotBeNull();

            ITraktUserCustomListsReorderPostResponse responseValue = response.Value;

            responseValue.Updated.Should().Be(6);
            responseValue.SkippedIds.Should().NotBeNull().And.HaveCount(1);
            responseValue.SkippedIds.Should().BeEquivalentTo(new List <uint> {
                12
            });
        }
        public override async Task <ITraktUserCustomListsReorderPost> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            CheckJsonTextReader(jsonReader);

            if (await jsonReader.ReadAsync(cancellationToken).ConfigureAwait(false) && jsonReader.TokenType == JsonToken.StartObject)
            {
                ITraktUserCustomListsReorderPost customListsReorderPost = new TraktUserCustomListsReorderPost();

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

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_RANK:
                        customListsReorderPost.Rank = await JsonReaderHelper.ReadUnsignedIntegerArrayAsync(jsonReader, cancellationToken).ConfigureAwait(false);

                        break;

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

                        break;
                    }
                }

                return(customListsReorderPost);
            }

            return(await Task.FromResult(default(ITraktUserCustomListsReorderPost)).ConfigureAwait(false));
        }
Ejemplo n.º 5
0
        public void Test_UserCustomListsReorderPostObjectJsonWriter_WriteObject_JsonWriter_Exceptions()
        {
            var traktJsonWriter = new UserCustomListsReorderPostObjectJsonWriter();
            ITraktUserCustomListsReorderPost traktUserCustomListsReorderPost = new TraktUserCustomListsReorderPost();
            Func <Task> action = () => traktJsonWriter.WriteObjectAsync(default(JsonTextWriter), traktUserCustomListsReorderPost);

            action.Should().Throw <ArgumentNullException>();
        }
Ejemplo n.º 6
0
        public async Task Test_UserCustomListsReorderPostObjectJsonWriter_WriteObject_StringWriter_Complete()
        {
            ITraktUserCustomListsReorderPost traktUserCustomListsReorderPost = new TraktUserCustomListsReorderPost
            {
                Rank = new List <uint> {
                    823, 224, 88768, 356456, 245, 2, 890
                }
            };

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

                json.Should().Be(@"{""rank"":[823,224,88768,356456,245,2,890]}");
            }
        }
        public void Test_TraktUserCustomListsReorderPost_Default_Constructor()
        {
            var traktUserCustomListsReorderPost = new TraktUserCustomListsReorderPost();

            traktUserCustomListsReorderPost.Rank.Should().BeNull();
        }