You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
3.1 KiB

7 years ago
  1. using Xunit;
  2. using TMDbLib.Objects.Discover;
  3. using TMDbLib.Objects.General;
  4. using System.Linq;
  5. using TMDbLib.Objects.Search;
  6. using TMDbLibTests.Helpers;
  7. using System;
  8. using TMDbLibTests.TestFramework;
  9. namespace TMDbLibTests
  10. {
  11. public class ClientDiscoverTests : TestBase
  12. {
  13. public ClientDiscoverTests(TestConfig testConfig) : base(testConfig)
  14. {
  15. }
  16. [Fact]
  17. public void TestDiscoverTvShowsNoParams()
  18. {
  19. // Ignore missing json
  20. IgnoreMissingJson("results[array] / media_type");
  21. TestHelpers.SearchPages(i => Config.Client.DiscoverTvShowsAsync().Query(i).Result);
  22. SearchContainer<SearchTv> result = Config.Client.DiscoverTvShowsAsync().Query().Result;
  23. Assert.NotNull(result);
  24. Assert.Equal(1, result.Page);
  25. Assert.NotNull(result.Results);
  26. Assert.True(result.Results.Any());
  27. }
  28. [Fact]
  29. public void TestDiscoverTvShows()
  30. {
  31. // Ignore missing json
  32. IgnoreMissingJson("results[array] / media_type");
  33. DiscoverTv query = Config.Client.DiscoverTvShowsAsync()
  34. .WhereVoteCountIsAtLeast(100)
  35. .WhereVoteAverageIsAtLeast(2);
  36. TestHelpers.SearchPages(i => query.Query(i).Result);
  37. }
  38. [Fact]
  39. public void TestDiscoverMoviesNoParams()
  40. {
  41. // Ignore missing json
  42. IgnoreMissingJson("results[array] / media_type");
  43. TestHelpers.SearchPages(i => Config.Client.DiscoverMoviesAsync().Query(i).Result);
  44. SearchContainer<SearchMovie> result = Config.Client.DiscoverMoviesAsync().Query().Result;
  45. Assert.NotNull(result);
  46. Assert.Equal(1, result.Page);
  47. Assert.NotNull(result.Results);
  48. Assert.True(result.Results.Any());
  49. }
  50. [Fact]
  51. public void TestDiscoverMovies()
  52. {
  53. // Ignore missing json
  54. IgnoreMissingJson("results[array] / media_type");
  55. DiscoverMovie query = Config.Client.DiscoverMoviesAsync()
  56. .WhereVoteCountIsAtLeast(1000)
  57. .WhereVoteAverageIsAtLeast(2);
  58. TestHelpers.SearchPages(i => query.Query(i).Result);
  59. }
  60. [Fact]
  61. public void TestDiscoverMoviesRegion()
  62. {
  63. // Ignore missing json
  64. IgnoreMissingJson("results[array] / media_type");
  65. DiscoverMovie query = Config.Client.DiscoverMoviesAsync().WhereReleaseDateIsInRegion("BR").WherePrimaryReleaseDateIsAfter(new DateTime(2017, 01, 01));
  66. TestHelpers.SearchPages(i => query.Query(i).Result);
  67. }
  68. [Fact]
  69. public void TestDiscoverMoviesLanguage()
  70. {
  71. // Ignore missing json
  72. IgnoreMissingJson("results[array] / media_type");
  73. DiscoverMovie query = Config.Client.DiscoverMoviesAsync().WhereLanguageIs("da-DK").WherePrimaryReleaseDateIsAfter(new DateTime(2017, 01, 01));
  74. Assert.Equal("Skønheden og Udyret", query.Query(0).Result.Results[11].Title);
  75. TestHelpers.SearchPages(i => query.Query(i).Result);
  76. }
  77. }
  78. }