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 TestTraktSearchFilterHasValues() { var filter = new TraktSearchFilter(); filter.HasValues.Should().BeFalse(); filter.WithStartYear(2010); filter.StartYear.Should().Be(2010); filter.HasValues.Should().BeTrue(); filter.Clear(); filter.HasValues.Should().BeFalse(); filter.WithEndYear(2016); filter.EndYear.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 TestTraktSearchFilterClearRatings() { var filter = new TraktSearchFilter(); filter.Ratings.Should().BeNull(); filter.WithRatings(60, 90); filter.Ratings.Should().NotBeNull(); filter.Ratings.Value.Begin.Should().Be(60); filter.Ratings.Value.End.Should().Be(90); filter.ClearRatings(); filter.Ratings.Should().BeNull(); }
public void TestTraktMovieFilterClear() { var filter = new TraktSearchFilter(); filter.WithYears(2016); filter.Years.Should().Be(2016); filter.WithGenres("action", "drama"); filter.Genres.Should().NotBeNull().And.HaveCount(2); filter.WithLanguages("de", "en"); filter.Languages.Should().NotBeNull().And.HaveCount(2); filter.WithCountries("gb", "us"); filter.Countries.Should().NotBeNull().And.HaveCount(2); filter.WithRuntimes(30, 180); filter.Runtimes.Should().NotBeNull(); filter.Runtimes.Value.Begin.Should().Be(30); filter.Runtimes.Value.End.Should().Be(180); filter.WithRatings(60, 90); filter.Ratings.Should().NotBeNull(); filter.Ratings.Value.Begin.Should().Be(60); filter.Ratings.Value.End.Should().Be(90); filter.Clear(); filter.Years.Should().Be(0); filter.Genres.Should().BeNull(); filter.Languages.Should().BeNull(); filter.Countries.Should().BeNull(); filter.Runtimes.Should().BeNull(); filter.Ratings.Should().BeNull(); filter.ToString().Should().NotBeNull().And.BeEmpty(); }
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}" } }); }