public void TestTraktMovieFilterToStringWithStartYear() { var filter = new TraktSearchFilter(); filter.ToString().Should().NotBeNull().And.BeEmpty(); var startYear = 2010; var years = $"{startYear}"; filter.WithStartYear(startYear); filter.ToString().Should().Be($"years={years}"); filter.WithGenres("action", "drama", "fantasy"); filter.ToString().Should().Be($"years={years}&genres=action,drama,fantasy"); filter.WithLanguages("de", "en", "es"); filter.ToString().Should().Be($"years={years}&genres=action,drama,fantasy&languages=de,en,es"); filter.WithCountries("gb", "us", "fr"); filter.ToString().Should().Be($"years={years}&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={years}&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={years}&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 TestTraktSearchFilterClearStartYear() { var filter = new TraktSearchFilter(); filter.StartYear.Should().NotHaveValue(); filter.WithStartYear(2010); filter.StartYear.Should().Be(2010); filter.ClearStartYear(); filter.StartYear.Should().NotHaveValue(); }
public void TestTraktSearchFilterGetParametersWithStartYear() { var filter = new TraktSearchFilter(); filter.GetParameters().Should().NotBeNull().And.BeEmpty(); var startYear = 2010; var years = $"{startYear}"; filter.WithStartYear(startYear); filter.GetParameters().Should().NotBeNull().And.HaveCount(1); filter.GetParameters().Should().Contain(new Dictionary <string, object>() { { "years", years } }); filter.WithGenres("action", "drama", "fantasy"); filter.GetParameters().Should().NotBeNull().And.HaveCount(2); filter.GetParameters().Should().Contain(new Dictionary <string, object>() { { "years", years }, { "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", years }, { "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", years }, { "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", years }, { "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", years }, { "genres", "action,drama,fantasy" }, { "languages", "de,en,es" }, { "countries", "gb,us,fr" }, { "runtimes", $"{runtimeBegin}-{runtimeEnd}" }, { "ratings", $"{ratingBegin}-{ratingEnd}" } }); }