public void TestTraktMovieFilterToString() { var filter = new TraktSearchFilter(); filter.ToString().Should().NotBeNull().And.BeEmpty(); var year = 2016; filter.WithYears(year); filter.ToString().Should().Be($"years={year}"); filter.WithGenres("action", "drama", "fantasy"); filter.ToString().Should().Be($"years={year}&genres=action,drama,fantasy"); filter.WithLanguages("de", "en", "es"); filter.ToString().Should().Be($"years={year}&genres=action,drama,fantasy&languages=de,en,es"); filter.WithCountries("gb", "us", "fr"); filter.ToString().Should().Be($"years={year}&genres=action,drama,fantasy&languages=de,en,es&countries=gb,us,fr"); var runtimeBegin = 50; var runtimeEnd = 100; filter.WithRuntimes(runtimeBegin, runtimeEnd); filter.ToString().Should().Be($"years={year}&genres=action,drama,fantasy&languages=de,en,es&countries=gb,us,fr" + $"&runtimes={runtimeBegin}-{runtimeEnd}"); var ratingBegin = 70; var ratingEnd = 90; filter.WithRatings(ratingBegin, ratingEnd); filter.ToString().Should().Be($"years={year}&genres=action,drama,fantasy&languages=de,en,es&countries=gb,us,fr" + $"&runtimes={runtimeBegin}-{runtimeEnd}&ratings={ratingBegin}-{ratingEnd}"); }
public void TestTraktMovieFilterHasValues() { var filter = new TraktSearchFilter(); filter.HasValues.Should().BeFalse(); filter.WithYears(2016); filter.Years.Should().Be(2016); filter.HasValues.Should().BeTrue(); filter.Clear(); filter.HasValues.Should().BeFalse(); filter.WithGenres("action", "drama"); filter.Genres.Should().NotBeNull().And.HaveCount(2); filter.HasValues.Should().BeTrue(); filter.Clear(); filter.HasValues.Should().BeFalse(); filter.WithLanguages("de", "en"); filter.Languages.Should().NotBeNull().And.HaveCount(2); filter.HasValues.Should().BeTrue(); filter.Clear(); filter.HasValues.Should().BeFalse(); filter.WithCountries("gb", "us"); filter.Countries.Should().NotBeNull().And.HaveCount(2); filter.HasValues.Should().BeTrue(); filter.Clear(); filter.HasValues.Should().BeFalse(); filter.WithRuntimes(30, 180); filter.Runtimes.Should().NotBeNull(); filter.Runtimes.Value.Begin.Should().Be(30); filter.Runtimes.Value.End.Should().Be(180); filter.HasValues.Should().BeTrue(); filter.Clear(); filter.HasValues.Should().BeFalse(); filter.WithRatings(60, 90); filter.Ratings.Should().NotBeNull(); filter.Ratings.Value.Begin.Should().Be(60); filter.Ratings.Value.End.Should().Be(90); filter.HasValues.Should().BeTrue(); filter.Clear(); filter.HasValues.Should().BeFalse(); }
public void TestTraktSearchFilterClearYears() { var filter = new TraktSearchFilter(); filter.StartYear.Should().NotHaveValue(); filter.EndYear.Should().NotHaveValue(); filter.WithYears(2010, 2016); filter.StartYear.Should().Be(2010); filter.EndYear.Should().Be(2016); filter.ClearYears(); filter.StartYear.Should().NotHaveValue(); filter.EndYear.Should().NotHaveValue(); }
public void TestTraktMovieFilterGetParameters() { var filter = new TraktSearchFilter(); filter.GetParameters().Should().NotBeNull().And.BeEmpty(); var year = 2016; filter.WithYears(year); filter.GetParameters().Should().NotBeNull().And.HaveCount(1); filter.GetParameters().Should().Contain(new Dictionary <string, object>() { { "years", "2016" } }); filter.WithGenres("action", "drama", "fantasy"); filter.GetParameters().Should().NotBeNull().And.HaveCount(2); filter.GetParameters().Should().Contain(new Dictionary <string, object>() { { "years", "2016" }, { "genres", "action,drama,fantasy" } }); filter.WithLanguages("de", "en", "es"); filter.GetParameters().Should().NotBeNull().And.HaveCount(3); filter.GetParameters().Should().Contain(new Dictionary <string, object>() { { "years", "2016" }, { "genres", "action,drama,fantasy" }, { "languages", "de,en,es" } }); filter.WithCountries("gb", "us", "fr"); filter.GetParameters().Should().NotBeNull().And.HaveCount(4); filter.GetParameters().Should().Contain(new Dictionary <string, object>() { { "years", "2016" }, { "genres", "action,drama,fantasy" }, { "languages", "de,en,es" }, { "countries", "gb,us,fr" } }); var runtimeBegin = 50; var runtimeEnd = 100; filter.WithRuntimes(runtimeBegin, runtimeEnd); filter.GetParameters().Should().NotBeNull().And.HaveCount(5); filter.GetParameters().Should().Contain(new Dictionary <string, object>() { { "years", "2016" }, { "genres", "action,drama,fantasy" }, { "languages", "de,en,es" }, { "countries", "gb,us,fr" }, { "runtimes", $"{runtimeBegin}-{runtimeEnd}" } }); var ratingBegin = 70; var ratingEnd = 90; filter.WithRatings(ratingBegin, ratingEnd); filter.GetParameters().Should().NotBeNull().And.HaveCount(6); filter.GetParameters().Should().Contain(new Dictionary <string, object>() { { "years", "2016" }, { "genres", "action,drama,fantasy" }, { "languages", "de,en,es" }, { "countries", "gb,us,fr" }, { "runtimes", $"{runtimeBegin}-{runtimeEnd}" }, { "ratings", $"{ratingBegin}-{ratingEnd}" } }); }