Пример #1
0
        public async Task Test_TraktUsersModule_GetPersonalRecommendations_Complete()
        {
            TraktClient client = TestUtility.GetOAuthMockClient(
                $"{GET_PERSONAL_RECOMMENDATIONS_URI}/{RECOMMENDATION_TYPE.UriName}/{RECOMMENDATION_SORT_ORDER.UriName}" +
                $"?extended={EXTENDED_INFO}&page={PAGE}&limit={RECOMMENDATIONS_LIMIT}",
                USER_RECOMMENDATIONS_JSON, PAGE, RECOMMENDATIONS_LIMIT, 1, RECOMMENDATIONS_ITEM_COUNT);

            var pagedParameters = new TraktPagedParameters(PAGE, RECOMMENDATIONS_LIMIT);

            TraktPagedResponse <ITraktRecommendation> response =
                await client.Users.GetPersonalRecommendationsAsync(USERNAME, RECOMMENDATION_TYPE, RECOMMENDATION_SORT_ORDER, EXTENDED_INFO, pagedParameters);

            response.Should().NotBeNull();
            response.IsSuccess.Should().BeTrue();
            response.HasValue.Should().BeTrue();
            response.Value.Should().NotBeNull().And.HaveCount(RECOMMENDATIONS_ITEM_COUNT);
            response.ItemCount.Should().HaveValue().And.Be(RECOMMENDATIONS_ITEM_COUNT);
            response.Limit.Should().Be(RECOMMENDATIONS_LIMIT);
            response.Page.Should().Be(PAGE);
            response.PageCount.Should().HaveValue().And.Be(1);
        }
        public async Task Test_TraktShowsModule_GetTrendingShows_With_Page()
        {
            TraktClient client = TestUtility.GetMockClient(
                $"{GET_TRENDING_SHOWS_URI}?page={PAGE}",
                TRENDING_SHOWS_JSON, PAGE, 10, 1, ITEM_COUNT, USER_COUNT);

            var pagedParameters = new TraktPagedParameters(PAGE);

            TraktPagedResponse <ITraktTrendingShow> response =
                await client.Shows.GetTrendingShowsAsync(null, null, pagedParameters);

            response.Should().NotBeNull();
            response.IsSuccess.Should().BeTrue();
            response.HasValue.Should().BeTrue();
            response.Value.Should().NotBeNull().And.HaveCount(ITEM_COUNT);
            response.ItemCount.Should().HaveValue().And.Be(ITEM_COUNT);
            response.Limit.Should().Be(10u);
            response.Page.Should().Be(PAGE);
            response.PageCount.Should().HaveValue().And.Be(1);
            response.TrendingUserCount.Should().HaveValue().And.Be(USER_COUNT);
        }
        public async Task Test_TraktSyncModule_GetWatchlist_With_Type_And_Sort_And_ExtendedInfo()
        {
            TraktClient client = TestUtility.GetOAuthMockClient(
                $"{GET_WATCHLIST_URI}/{WATCHLIST_ITEM_TYPE.UriName}/{WATCHLIST_SORT_ORDER.UriName}?extended={EXTENDED_INFO}",
                WATCHLIST_JSON, PAGE, 10, 1, ITEM_COUNT,
                sortBy: WATCHLIST_SORT_BY, sortHow: WATCHLIST_SORT_HOW);

            TraktPagedResponse <ITraktWatchlistItem> response =
                await client.Sync.GetWatchlistAsync(WATCHLIST_ITEM_TYPE, WATCHLIST_SORT_ORDER, EXTENDED_INFO);

            response.Should().NotBeNull();
            response.IsSuccess.Should().BeTrue();
            response.HasValue.Should().BeTrue();
            response.Value.Should().NotBeNull().And.HaveCount(ITEM_COUNT);
            response.ItemCount.Should().HaveValue().And.Be(ITEM_COUNT);
            response.Limit.Should().Be(10u);
            response.Page.Should().Be(PAGE);
            response.PageCount.Should().HaveValue().And.Be(1);
            response.SortBy.Should().NotBeNull().And.Be(WATCHLIST_SORT_BY);
            response.SortHow.Should().NotBeNull().And.Be(WATCHLIST_SORT_HOW);
        }
Пример #4
0
        public async Task Test_TraktUsersModule_GetHiddenItems_Complete()
        {
            TraktClient client = TestUtility.GetOAuthMockClient(
                $"{GetHiddenItemsUri}?type={HIDDEN_ITEM_TYPE.UriName}" +
                $"&extended={EXTENDED_INFO}&page={PAGE}&limit={HIDDEN_ITEMS_LIMIT}",
                HIDDEN_ITEMS_JSON, PAGE, HIDDEN_ITEMS_LIMIT, 1, HIDDEN_ITEMS_COUNT);

            var pagedParameters = new TraktPagedParameters(PAGE, HIDDEN_ITEMS_LIMIT);

            TraktPagedResponse <ITraktUserHiddenItem> response =
                await client.Users.GetHiddenItemsAsync(HIDDEN_ITEMS_SECTION, HIDDEN_ITEM_TYPE, EXTENDED_INFO, pagedParameters);

            response.Should().NotBeNull();
            response.IsSuccess.Should().BeTrue();
            response.HasValue.Should().BeTrue();
            response.Value.Should().NotBeNull().And.HaveCount(HIDDEN_ITEMS_COUNT);
            response.ItemCount.Should().HaveValue().And.Be(HIDDEN_ITEMS_COUNT);
            response.Limit.Should().Be(HIDDEN_ITEMS_LIMIT);
            response.Page.Should().Be(PAGE);
            response.PageCount.Should().HaveValue().And.Be(1);
        }
        public async Task Test_TraktUsersModule_GetWatchlist_With_Type_And_Sort()
        {
            TraktClient client = TestUtility.GetMockClient(
                $"{GET_WATCHLIST_URI}/{WATCHLIST_ITEM_TYPE.UriName}/{WATCHLIST_SORT_ORDER.UriName}",
                WATCHLIST_JSON, 1, 10, 1, WATCHLIST_ITEM_COUNT,
                sortBy: SORT_BY, sortHow: SORT_HOW);

            TraktPagedResponse <ITraktWatchlistItem> response =
                await client.Users.GetWatchlistAsync(USERNAME, WATCHLIST_ITEM_TYPE, WATCHLIST_SORT_ORDER);

            response.Should().NotBeNull();
            response.IsSuccess.Should().BeTrue();
            response.HasValue.Should().BeTrue();
            response.Value.Should().NotBeNull().And.HaveCount(WATCHLIST_ITEM_COUNT);
            response.ItemCount.Should().HaveValue().And.Be(WATCHLIST_ITEM_COUNT);
            response.Limit.Should().Be(10u);
            response.Page.Should().Be(1u);
            response.PageCount.Should().HaveValue().And.Be(1);
            response.SortBy.Should().NotBeNull().And.Be(SORT_BY);
            response.SortHow.Should().NotBeNull().And.Be(SORT_HOW);
        }
        public async Task Test_TraktUsersModule_GetWatchlist_With_ExtendedInfo()
        {
            TraktClient client = TestUtility.GetMockClient(
                $"{GET_WATCHLIST_URI}?extended={EXTENDED_INFO}",
                WATCHLIST_JSON, 1, 10, 1, WATCHLIST_ITEM_COUNT,
                sortBy: SORT_BY, sortHow: SORT_HOW);

            TraktPagedResponse <ITraktWatchlistItem> response =
                await client.Users.GetWatchlistAsync(USERNAME, null, null, EXTENDED_INFO);

            response.Should().NotBeNull();
            response.IsSuccess.Should().BeTrue();
            response.HasValue.Should().BeTrue();
            response.Value.Should().NotBeNull().And.HaveCount(WATCHLIST_ITEM_COUNT);
            response.ItemCount.Should().HaveValue().And.Be(WATCHLIST_ITEM_COUNT);
            response.Limit.Should().Be(10u);
            response.Page.Should().Be(1u);
            response.PageCount.Should().HaveValue().And.Be(1);
            response.SortBy.Should().NotBeNull().And.Be(SORT_BY);
            response.SortHow.Should().NotBeNull().And.Be(SORT_HOW);
        }
Пример #7
0
        public async Task Test_TraktUsersModule_GetWatchlist_With_OAuth_Enforced()
        {
            TraktClient client = TestUtility.GetOAuthMockClient(
                GET_WATCHLIST_URI,
                WATCHLIST_JSON, 1, 10, 1, WATCHLIST_ITEM_COUNT,
                sortBy: SORT_BY, sortHow: SORT_HOW);

            client.Configuration.ForceAuthorization = true;

            TraktPagedResponse <ITraktWatchlistItem> response = await client.Users.GetWatchlistAsync(USERNAME);

            response.Should().NotBeNull();
            response.IsSuccess.Should().BeTrue();
            response.HasValue.Should().BeTrue();
            response.Value.Should().NotBeNull().And.HaveCount(WATCHLIST_ITEM_COUNT);
            response.ItemCount.Should().HaveValue().And.Be(WATCHLIST_ITEM_COUNT);
            response.Limit.Should().Be(10u);
            response.Page.Should().Be(1u);
            response.PageCount.Should().HaveValue().And.Be(1);
            response.SortBy.Should().NotBeNull().And.Be(SORT_BY);
            response.SortHow.Should().NotBeNull().And.Be(SORT_HOW);
        }
Пример #8
0
        public async Task Test_TraktSyncModule_GetRatings_Complete()
        {
            var ratingsFilter = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

            TraktClient client = TestUtility.GetOAuthMockClient(
                $"{GET_RATINGS_URI}/{RATINGS_ITEM_TYPE.UriName}/{BuildRatingsFilterString(ratingsFilter)}?extended={EXTENDED_INFO}&page={PAGE}&limit={LIMIT}",
                RATINGS_JSON, 1, 10, 1, RATINGS_ITEM_COUNT);

            var pagedParameters = new TraktPagedParameters(PAGE, LIMIT);

            TraktPagedResponse <ITraktRatingsItem> response =
                await client.Sync.GetRatingsAsync(RATINGS_ITEM_TYPE, ratingsFilter, EXTENDED_INFO, pagedParameters);

            response.Should().NotBeNull();
            response.IsSuccess.Should().BeTrue();
            response.HasValue.Should().BeTrue();
            response.Value.Should().NotBeNull().And.HaveCount(4);
            response.ItemCount.Should().HaveValue().And.Be(RATINGS_ITEM_COUNT);
            response.Limit.Should().Be(10u);
            response.Page.Should().Be(1u);
            response.PageCount.Should().HaveValue().And.Be(1);
        }
        public async Task Test_TraktUsersModule_GetComments_Complete()
        {
            TraktClient client = TestUtility.GetMockClient(
                $"{GET_COMMENTS_URI}/{COMMENT_TYPE.UriName}/{OBJECT_TYPE.UriName}" +
                $"?extended={EXTENDED_INFO}&page={PAGE}&limit={COMMENTS_LIMIT}",
                USER_COMMENTS_JSON, PAGE, COMMENTS_LIMIT, 1, COMMENTS_ITEM_COUNT);

            var pagedParameters = new TraktPagedParameters(PAGE, COMMENTS_LIMIT);

            TraktPagedResponse <ITraktUserComment> response =
                await client.Users.GetCommentsAsync(USERNAME, COMMENT_TYPE, OBJECT_TYPE,
                                                    null, EXTENDED_INFO, pagedParameters);

            response.Should().NotBeNull();
            response.IsSuccess.Should().BeTrue();
            response.HasValue.Should().BeTrue();
            response.Value.Should().NotBeNull().And.HaveCount(COMMENTS_ITEM_COUNT);
            response.ItemCount.Should().HaveValue().And.Be(COMMENTS_ITEM_COUNT);
            response.Limit.Should().Be(COMMENTS_LIMIT);
            response.Page.Should().Be(PAGE);
            response.PageCount.Should().HaveValue().And.Be(1);
        }
Пример #10
0
        public async Task Test_TraktSyncModule_GetPlaybackProgress_Complete()
        {
            TraktClient client = TestUtility.GetOAuthMockClient(
                $"{GET_PLAYBACK_PROGRESS_URI}/{PLAYBACK_PROGRESS_TYPE.UriName}" +
                $"?start_at={PLAYBACK_PROGRESS_START_AT.ToTraktLongDateTimeString()}&end_at={PLAYBACK_PROGRESS_END_AT.ToTraktLongDateTimeString()}" +
                $"&page={PAGE}&limit={PLAYBACK_PROGRESS_LIMIT}",
                PLAYBACK_PROGRESS_JSON, 1, 10, 1, PLAYBACK_PROGRESS_ITEM_COUNT);

            var pagedParameters = new TraktPagedParameters(PAGE, PLAYBACK_PROGRESS_LIMIT);

            TraktPagedResponse <ITraktSyncPlaybackProgressItem> response =
                await client.Sync.GetPlaybackProgressAsync(PLAYBACK_PROGRESS_TYPE, PLAYBACK_PROGRESS_START_AT, PLAYBACK_PROGRESS_END_AT, pagedParameters);

            response.Should().NotBeNull();
            response.IsSuccess.Should().BeTrue();
            response.HasValue.Should().BeTrue();
            response.Value.Should().NotBeNull().And.HaveCount(2);
            response.ItemCount.Should().HaveValue().And.Be(PLAYBACK_PROGRESS_ITEM_COUNT);
            response.Limit.Should().Be(10u);
            response.Page.Should().Be(1u);
            response.PageCount.Should().HaveValue().And.Be(1);
        }
Пример #11
0
        public async Task Test_TraktUsersModule_GetWatchlist_With_Page_And_Limit()
        {
            TraktClient client = TestUtility.GetMockClient(
                $"{GET_WATCHLIST_URI}?page={PAGE}&limit={WATCHLIST_LIMIT}",
                WATCHLIST_JSON, PAGE, WATCHLIST_LIMIT, 1, WATCHLIST_ITEM_COUNT,
                sortBy: SORT_BY, sortHow: SORT_HOW);

            var pagedParameters = new TraktPagedParameters(PAGE, WATCHLIST_LIMIT);

            TraktPagedResponse <ITraktWatchlistItem> response =
                await client.Users.GetWatchlistAsync(USERNAME, null, null, pagedParameters);

            response.Should().NotBeNull();
            response.IsSuccess.Should().BeTrue();
            response.HasValue.Should().BeTrue();
            response.Value.Should().NotBeNull().And.HaveCount(WATCHLIST_ITEM_COUNT);
            response.ItemCount.Should().HaveValue().And.Be(WATCHLIST_ITEM_COUNT);
            response.Limit.Should().Be(WATCHLIST_LIMIT);
            response.Page.Should().Be(PAGE);
            response.PageCount.Should().HaveValue().And.Be(1);
            response.SortBy.Should().NotBeNull().And.Be(SORT_BY);
            response.SortHow.Should().NotBeNull().And.Be(SORT_HOW);
        }
Пример #12
0
        public async Task Test_TraktUsersModule_GetWatchlist_With_Type_And_ExtendedInfo_And_Limit()
        {
            TraktClient client = TestUtility.GetMockClient(
                $"{GET_WATCHLIST_URI}/{WATCHLIST_ITEM_TYPE.UriName}?extended={EXTENDED_INFO}&limit={WATCHLIST_LIMIT}",
                WATCHLIST_JSON, 1, WATCHLIST_LIMIT, 1, WATCHLIST_ITEM_COUNT,
                sortBy: SORT_BY, sortHow: SORT_HOW);

            var pagedParameters = new TraktPagedParameters(null, WATCHLIST_LIMIT);

            TraktPagedResponse <ITraktWatchlistItem> response =
                await client.Users.GetWatchlistAsync(USERNAME, WATCHLIST_ITEM_TYPE, EXTENDED_INFO, pagedParameters);

            response.Should().NotBeNull();
            response.IsSuccess.Should().BeTrue();
            response.HasValue.Should().BeTrue();
            response.Value.Should().NotBeNull().And.HaveCount(WATCHLIST_ITEM_COUNT);
            response.ItemCount.Should().HaveValue().And.Be(WATCHLIST_ITEM_COUNT);
            response.Limit.Should().Be(WATCHLIST_LIMIT);
            response.Page.Should().Be(1u);
            response.PageCount.Should().HaveValue().And.Be(1);
            response.SortBy.Should().NotBeNull().And.Be(SORT_BY);
            response.SortHow.Should().NotBeNull().And.Be(SORT_HOW);
        }
Пример #13
0
        public async Task Test_TraktSyncModule_GetWatchlist_With_Limit()
        {
            TraktClient client = TestUtility.GetOAuthMockClient(
                $"{GET_WATCHLIST_URI}?limit={LIMIT}",
                WATCHLIST_JSON, 1, LIMIT, 1, ITEM_COUNT,
                sortBy: WATCHLIST_SORT_BY, sortHow: WATCHLIST_SORT_HOW);

            var pagedParameters = new TraktPagedParameters(null, LIMIT);

            TraktPagedResponse <ITraktWatchlistItem> response =
                await client.Sync.GetWatchlistAsync(null, null, pagedParameters);

            response.Should().NotBeNull();
            response.IsSuccess.Should().BeTrue();
            response.HasValue.Should().BeTrue();
            response.Value.Should().NotBeNull().And.HaveCount(ITEM_COUNT);
            response.ItemCount.Should().HaveValue().And.Be(ITEM_COUNT);
            response.Limit.Should().Be(LIMIT);
            response.Page.Should().Be(1u);
            response.PageCount.Should().HaveValue().And.Be(1);
            response.SortBy.Should().NotBeNull().And.Be(WATCHLIST_SORT_BY);
            response.SortHow.Should().NotBeNull().And.Be(WATCHLIST_SORT_HOW);
        }
Пример #14
0
        public async Task Test_TraktSyncModule_GetWatchlist_With_ExtendedInfo_And_Page()
        {
            TraktClient client = TestUtility.GetOAuthMockClient(
                $"{GET_WATCHLIST_URI}?extended={EXTENDED_INFO}&page={PAGE}",
                WATCHLIST_JSON, PAGE, 10, 1, ITEM_COUNT,
                sortBy: WATCHLIST_SORT_BY, sortHow: WATCHLIST_SORT_HOW);

            var pagedParameters = new TraktPagedParameters(PAGE);

            TraktPagedResponse <ITraktWatchlistItem> response =
                await client.Sync.GetWatchlistAsync(null, EXTENDED_INFO, pagedParameters);

            response.Should().NotBeNull();
            response.IsSuccess.Should().BeTrue();
            response.HasValue.Should().BeTrue();
            response.Value.Should().NotBeNull().And.HaveCount(ITEM_COUNT);
            response.ItemCount.Should().HaveValue().And.Be(ITEM_COUNT);
            response.Limit.Should().Be(10u);
            response.Page.Should().Be(PAGE);
            response.PageCount.Should().HaveValue().And.Be(1);
            response.SortBy.Should().NotBeNull().And.Be(WATCHLIST_SORT_BY);
            response.SortHow.Should().NotBeNull().And.Be(WATCHLIST_SORT_HOW);
        }