Esempio n. 1
0
        public void Test_TraktCalendarFilterBuilder_GetParameters()
        {
            ITraktCalendarFilter filter = TraktFilterDirectory.CalendarFilter
                                          .WithQuery("query")
                                          .WithYears(2016, 2018)
                                          .WithGenres("action", "drama")
                                          .WithLanguages("de", "en")
                                          .WithCountries("gb", "us")
                                          .WithRuntimes(30, 180)
                                          .WithRatings(60, 90)
                                          .Build();

            filter.GetParameters().Should().NotBeNull().And.HaveCount(7);

            filter.GetParameters().Should().Contain(new Dictionary <string, object>()
            {
                { "query", "query" },
                { "years", "2016-2018" },
                { "genres", "action,drama" },
                { "languages", "de,en" },
                { "countries", "gb,us" },
                { "runtimes", "30-180" },
                { "ratings", "60-90" }
            });
        }
Esempio n. 2
0
        public void Test_TraktCalendarFilterBuilder_HasValues()
        {
            ITraktCalendarFilter filter = TraktFilterDirectory.CalendarFilter.Build();

            filter.HasValues.Should().BeFalse();

            filter = TraktFilterDirectory.CalendarFilter.WithQuery("query").Build();
            filter.HasValues.Should().BeTrue();

            filter = TraktFilterDirectory.CalendarFilter.WithYear(2018).Build();
            filter.HasValues.Should().BeTrue();

            filter = TraktFilterDirectory.CalendarFilter.WithYears(2016, 2018).Build();
            filter.HasValues.Should().BeTrue();

            filter = TraktFilterDirectory.CalendarFilter.WithGenres("action", "drama").Build();
            filter.HasValues.Should().BeTrue();

            filter = TraktFilterDirectory.CalendarFilter.WithLanguages("de", "en").Build();
            filter.HasValues.Should().BeTrue();

            filter = TraktFilterDirectory.CalendarFilter.WithCountries("gb", "us").Build();
            filter.HasValues.Should().BeTrue();

            filter = TraktFilterDirectory.CalendarFilter.WithRuntimes(30, 180).Build();
            filter.HasValues.Should().BeTrue();

            filter = TraktFilterDirectory.CalendarFilter.WithRatings(60, 90).Build();
            filter.HasValues.Should().BeTrue();
        }
Esempio n. 3
0
        public void Test_TraktCalendarFilterBuilder_GetParameters_With_Query()
        {
            ITraktCalendarFilter filter = TraktFilterDirectory.CalendarFilter.WithQuery("query").Build();

            filter.GetParameters().Should().NotBeNull().And.HaveCount(1);
            filter.GetParameters().Should().Contain(new Dictionary <string, object>()
            {
                { "query", "query" }
            });
        }
Esempio n. 4
0
        public void Test_TraktCalendarFilterBuilder_GetParameters_With_Years_Reversed()
        {
            ITraktCalendarFilter filter = TraktFilterDirectory.CalendarFilter.WithYears(2018, 2016).Build();

            filter.GetParameters().Should().NotBeNull().And.HaveCount(1);
            filter.GetParameters().Should().Contain(new Dictionary <string, object>()
            {
                { "years", "2016-2018" }
            });
        }
Esempio n. 5
0
        public void Test_TraktCalendarFilterBuilder_GetParameters_With_Ratings()
        {
            ITraktCalendarFilter filter = TraktFilterDirectory.CalendarFilter.WithRatings(60, 90).Build();

            filter.GetParameters().Should().NotBeNull().And.HaveCount(1);
            filter.GetParameters().Should().Contain(new Dictionary <string, object>()
            {
                { "ratings", "60-90" }
            });
        }
Esempio n. 6
0
        public void Test_TraktCalendarFilterBuilder_GetParameters_With_Runtimes()
        {
            ITraktCalendarFilter filter = TraktFilterDirectory.CalendarFilter.WithRuntimes(30, 180).Build();

            filter.GetParameters().Should().NotBeNull().And.HaveCount(1);
            filter.GetParameters().Should().Contain(new Dictionary <string, object>()
            {
                { "runtimes", "30-180" }
            });
        }
Esempio n. 7
0
        public void Test_TraktCalendarFilterBuilder_GetParameters_With_Countries()
        {
            ITraktCalendarFilter filter = TraktFilterDirectory.CalendarFilter.WithCountries("gb", "us").Build();

            filter.GetParameters().Should().NotBeNull().And.HaveCount(1);
            filter.GetParameters().Should().Contain(new Dictionary <string, object>()
            {
                { "countries", "gb,us" }
            });
        }
Esempio n. 8
0
        public void Test_TraktCalendarFilterBuilder_GetParameters_With_Languages()
        {
            ITraktCalendarFilter filter = TraktFilterDirectory.CalendarFilter.WithLanguages("de", "en").Build();

            filter.GetParameters().Should().NotBeNull().And.HaveCount(1);
            filter.GetParameters().Should().Contain(new Dictionary <string, object>()
            {
                { "languages", "de,en" }
            });
        }
Esempio n. 9
0
        public void Test_TraktCalendarFilterBuilder_GetParameters_With_Genres()
        {
            ITraktCalendarFilter filter = TraktFilterDirectory.CalendarFilter.WithGenres("action", "drama").Build();

            filter.GetParameters().Should().NotBeNull().And.HaveCount(1);
            filter.GetParameters().Should().Contain(new Dictionary <string, object>()
            {
                { "genres", "action,drama" }
            });
        }
Esempio n. 10
0
        public void Test_TraktCalendarFilterBuilder_ToString()
        {
            ITraktCalendarFilter filter = TraktFilterDirectory.CalendarFilter
                                          .WithQuery("query")
                                          .WithYears(2016, 2018)
                                          .WithGenres("action", "drama")
                                          .WithLanguages("de", "en")
                                          .WithCountries("gb", "us")
                                          .WithRuntimes(30, 180)
                                          .WithRatings(60, 90)
                                          .Build();

            filter.ToString().Should().Be("query=query&years=2016-2018&genres=action,drama&languages=de,en" +
                                          "&countries=gb,us&runtimes=30-180&ratings=60-90");
        }
Esempio n. 11
0
        public void Test_TraktCalendarFilterBuilder_EmptyFilter()
        {
            ITraktCalendarFilter filter = TraktFilterDirectory.CalendarFilter.Build();

            filter.Query.Should().BeNull();
            filter.Year.Should().BeNull();
            filter.Years.Should().BeNull();
            filter.Genres.Should().BeNull();
            filter.Languages.Should().BeNull();
            filter.Countries.Should().BeNull();
            filter.Runtimes.Should().BeNull();
            filter.Ratings.Should().BeNull();
            filter.HasValues.Should().BeFalse();
            filter.ToString().Should().NotBeNull().And.BeEmpty();
            filter.GetParameters().Should().NotBeNull().And.BeEmpty();
        }
        /// <summary>
        /// Gets all new users <see cref="ITraktCalendarShow" />s airing during the given time period.
        /// <para>OAuth authorization required.</para>
        /// <para>
        /// See <a href="http://docs.trakt.apiary.io/#reference/calendars/my-new-shows/get-new-shows">"Trakt API Doc - Calendars: My New Shows"</a> for more information.
        /// </para>
        /// </summary>
        /// <param name="startDate">The date, on which the time period should start. Defaults to today. Will be converted to the Trakt date-format.</param>
        /// <param name="days">1 - 31 days, specifying the length of the time period. Defaults to 7 days.</param>
        /// <param name="extendedInfo">
        /// The extended info, which determines how much data about the shows should be queried.
        /// See also <seealso cref="TraktExtendedInfo" />.
        /// </param>
        /// <param name="filter">Optional filters for genres, languages, year, runtimes, ratings, etc. See also <seealso cref="TraktCalendarFilter" />.</param>
        /// <param name="cancellationToken">
        /// Propagates notification that the request should be canceled.<para/>
        /// If provided, the exception <see cref="OperationCanceledException" /> should be catched.
        /// </param>
        /// <returns>A list of <see cref="ITraktCalendarShow" /> instances.</returns>
        /// <exception cref="TraktException">Thrown, if the request fails.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown, if the given days value is not between 1 and 31.</exception>
        public Task <TraktListResponse <ITraktCalendarShow> > GetUserNewShowsAsync(DateTime?startDate                  = null, int?days = null,
                                                                                   TraktExtendedInfo extendedInfo      = null,
                                                                                   ITraktCalendarFilter filter         = null,
                                                                                   CancellationToken cancellationToken = default)
        {
            var requestHandler = new RequestHandler(Client);

            return(requestHandler.ExecuteListRequestAsync(new CalendarUserNewShowsRequest
            {
                StartDate = startDate,
                Days = days,
                ExtendedInfo = extendedInfo,
                Filter = filter
            },
                                                          cancellationToken));
        }
Esempio n. 13
0
        public void Test_TraktCalendarFilterBuilder_ToString_With_Query()
        {
            ITraktCalendarFilter filter = TraktFilterDirectory.CalendarFilter.WithQuery("query").Build();

            filter.ToString().Should().Be("query=query");
        }
Esempio n. 14
0
        public void Test_TraktCalendarFilterBuilder_ToString_With_Genres()
        {
            ITraktCalendarFilter filter = TraktFilterDirectory.CalendarFilter.WithGenres("action", "drama").Build();

            filter.ToString().Should().Be("genres=action,drama");
        }
Esempio n. 15
0
        public void Test_TraktCalendarFilterBuilder_ToString_With_Years_Reversed()
        {
            ITraktCalendarFilter filter = TraktFilterDirectory.CalendarFilter.WithYears(2018, 2016).Build();

            filter.ToString().Should().Be("years=2016-2018");
        }
Esempio n. 16
0
        public void Test_TraktCalendarFilterBuilder_ToString_With_Languages()
        {
            ITraktCalendarFilter filter = TraktFilterDirectory.CalendarFilter.WithLanguages("de", "en").Build();

            filter.ToString().Should().Be("languages=de,en");
        }
Esempio n. 17
0
        public void Test_TraktCalendarFilterBuilder_ToString_With_Countries()
        {
            ITraktCalendarFilter filter = TraktFilterDirectory.CalendarFilter.WithCountries("gb", "us").Build();

            filter.ToString().Should().Be("countries=gb,us");
        }
Esempio n. 18
0
        public void Test_TraktCalendarFilterBuilder_ToString_With_Ratings()
        {
            ITraktCalendarFilter filter = TraktFilterDirectory.CalendarFilter.WithRatings(60, 90).Build();

            filter.ToString().Should().Be("ratings=60-90");
        }
Esempio n. 19
0
        public void Test_TraktCalendarFilterBuilder_ToString_With_Runtimes()
        {
            ITraktCalendarFilter filter = TraktFilterDirectory.CalendarFilter.WithRuntimes(30, 180).Build();

            filter.ToString().Should().Be("runtimes=30-180");
        }