mirror of
https://github.com/jellyfin/TMDbLib.git
synced 2024-11-23 05:40:12 +00:00
parent
270a4c2200
commit
4b9e2173f2
12
TMDbLib.sln
12
TMDbLib.sln
@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TMDbLibTests", "TMDbLibTests\TMDbLibTests.csproj", "{00AB08ED-9484-4AAE-9C8C-D19E40325E16}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{545A7CAB-316A-4C5E-AB6B-BF10A0C3EDA9}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.nuget\NuGet.Config = .nuget\NuGet.Config
|
||||
@ -16,16 +14,14 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TMDbLib", "TMDbLib\TMDbLib.
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TestApplication", "TestApplication\TestApplication.xproj", "{4C8E1F72-DA9D-4EC6-8C04-5EC8EDC59FA1}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TMDbLibTests", "TMDbLibTests\TMDbLibTests.xproj", "{228615EB-BFA3-44A7-8648-A7EA48470777}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{00AB08ED-9484-4AAE-9C8C-D19E40325E16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{00AB08ED-9484-4AAE-9C8C-D19E40325E16}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{00AB08ED-9484-4AAE-9C8C-D19E40325E16}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{00AB08ED-9484-4AAE-9C8C-D19E40325E16}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A7D4744C-9EF2-4CC3-B786-E8E568874933}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A7D4744C-9EF2-4CC3-B786-E8E568874933}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A7D4744C-9EF2-4CC3-B786-E8E568874933}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@ -34,6 +30,10 @@ Global
|
||||
{4C8E1F72-DA9D-4EC6-8C04-5EC8EDC59FA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4C8E1F72-DA9D-4EC6-8C04-5EC8EDC59FA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4C8E1F72-DA9D-4EC6-8C04-5EC8EDC59FA1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{228615EB-BFA3-44A7-8648-A7EA48470777}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{228615EB-BFA3-44A7-8648-A7EA48470777}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{228615EB-BFA3-44A7-8648-A7EA48470777}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{228615EB-BFA3-44A7-8648-A7EA48470777}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -1,341 +1,324 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Account;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.Lists;
|
||||
using TMDbLib.Objects.Search;
|
||||
using TMDbLibTests.Exceptions;
|
||||
using TMDbLibTests.Helpers;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientAccountTests : TestBase
|
||||
{
|
||||
private TestConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public override void Initiator()
|
||||
public ClientAccountTests() : base()
|
||||
{
|
||||
base.Initiator();
|
||||
|
||||
_config = new TestConfig();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(_config.UserSessionId))
|
||||
throw new ConfigurationErrorsException("To successfully complete the ClientAccountTests you will need to specify a valid 'UserSessionId' in the test config file");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(UserSessionRequiredException))]
|
||||
[Fact]
|
||||
public void TestAccountGetDetailsGuestAccount()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.GuestTestSessionId, SessionType.GuestSession);
|
||||
try
|
||||
{
|
||||
_config.Client.AccountGetDetailsAsync().Wait();
|
||||
}
|
||||
catch (AggregateException ex)
|
||||
{
|
||||
throw ex.InnerException;
|
||||
}
|
||||
|
||||
// Should always throw exception
|
||||
Assert.Fail();
|
||||
Assert.Throws<UserSessionRequiredException>(() => _config.Client.AccountGetDetailsAsync().Sync());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestAccountGetDetailsUserAccount()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
AccountDetails account = _config.Client.AccountGetDetailsAsync().Result;
|
||||
AccountDetails account = _config.Client.AccountGetDetailsAsync().Sync();
|
||||
|
||||
// Naturally the specified account must have these values populated for the test to pass
|
||||
Assert.IsNotNull(account);
|
||||
Assert.IsTrue(account.Id > 1);
|
||||
Assert.AreEqual("Test Name", account.Name);
|
||||
Assert.AreEqual("TMDbTestAccount", account.Username);
|
||||
Assert.AreEqual("BE", account.Iso_3166_1);
|
||||
Assert.AreEqual("en", account.Iso_639_1);
|
||||
Assert.NotNull(account);
|
||||
Assert.True(account.Id > 1);
|
||||
Assert.Equal("Test Name", account.Name);
|
||||
Assert.Equal("TMDbTestAccount", account.Username);
|
||||
Assert.Equal("BE", account.Iso_3166_1);
|
||||
Assert.Equal("en", account.Iso_639_1);
|
||||
|
||||
Assert.IsNotNull(account.Avatar);
|
||||
Assert.IsNotNull(account.Avatar.Gravatar);
|
||||
Assert.AreEqual("7cf5357dbc2014cbd616257c358ea0a1", account.Avatar.Gravatar.Hash);
|
||||
Assert.NotNull(account.Avatar);
|
||||
Assert.NotNull(account.Avatar.Gravatar);
|
||||
Assert.Equal("7cf5357dbc2014cbd616257c358ea0a1", account.Avatar.Gravatar.Hash);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestAccountAccountGetLists()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
TestHelpers.SearchPages(i => _config.Client.AccountGetListsAsync(i).Result);
|
||||
List list = _config.Client.AccountGetListsAsync().Result.Results[0];
|
||||
List list = _config.Client.AccountGetListsAsync().Sync().Results[0];
|
||||
|
||||
Assert.IsNotNull(list.Id);
|
||||
Assert.IsNotNull(list.Name);
|
||||
Assert.IsNull(list.PosterPath);
|
||||
Assert.IsNotNull(list.Description);
|
||||
Assert.IsNotNull(list.ListType);
|
||||
Assert.IsNotNull(list.Iso_639_1);
|
||||
Assert.IsNull(list.Items);
|
||||
Assert.IsNull(list.CreatedBy);
|
||||
Assert.NotNull(list.Id);
|
||||
Assert.NotNull(list.Name);
|
||||
Assert.Null(list.PosterPath);
|
||||
Assert.NotNull(list.Description);
|
||||
Assert.NotNull(list.ListType);
|
||||
Assert.NotNull(list.Iso_639_1);
|
||||
Assert.Null(list.Items);
|
||||
Assert.Null(list.CreatedBy);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestAccountGetFavoriteMovies()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
TestHelpers.SearchPages(i => _config.Client.AccountGetFavoriteMoviesAsync(i).Result);
|
||||
SearchMovie movie = _config.Client.AccountGetFavoriteMoviesAsync().Result.Results[0];
|
||||
SearchMovie movie = _config.Client.AccountGetFavoriteMoviesAsync().Sync().Results[0];
|
||||
|
||||
// Requires that you have marked at least one movie as favorite else this test will fail
|
||||
Assert.IsTrue(movie.Id > 0);
|
||||
Assert.IsNotNull(movie.Title);
|
||||
Assert.IsNotNull(movie.PosterPath);
|
||||
Assert.IsNotNull(movie.BackdropPath);
|
||||
Assert.IsNotNull(movie.OriginalTitle);
|
||||
Assert.IsNotNull(movie.Overview);
|
||||
Assert.IsNotNull(movie.OriginalLanguage);
|
||||
Assert.IsNotNull(movie.ReleaseDate);
|
||||
Assert.IsTrue(movie.VoteCount > 0);
|
||||
Assert.IsTrue(movie.VoteAverage > 0);
|
||||
Assert.IsTrue(movie.Popularity > 0);
|
||||
Assert.True(movie.Id > 0);
|
||||
Assert.NotNull(movie.Title);
|
||||
Assert.NotNull(movie.PosterPath);
|
||||
Assert.NotNull(movie.BackdropPath);
|
||||
Assert.NotNull(movie.OriginalTitle);
|
||||
Assert.NotNull(movie.Overview);
|
||||
Assert.NotNull(movie.OriginalLanguage);
|
||||
Assert.NotNull(movie.ReleaseDate);
|
||||
Assert.True(movie.VoteCount > 0);
|
||||
Assert.True(movie.VoteAverage > 0);
|
||||
Assert.True(movie.Popularity > 0);
|
||||
|
||||
Assert.IsNotNull(movie.GenreIds);
|
||||
Assert.IsTrue(movie.GenreIds.Any());
|
||||
Assert.NotNull(movie.GenreIds);
|
||||
Assert.True(movie.GenreIds.Any());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestAccountGetFavoriteTv()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
TestHelpers.SearchPages(i => _config.Client.AccountGetFavoriteTvAsync(i).Result);
|
||||
SearchTv tvShow = _config.Client.AccountGetFavoriteTvAsync().Result.Results[0];
|
||||
SearchTv tvShow = _config.Client.AccountGetFavoriteTvAsync().Sync().Results[0];
|
||||
|
||||
// Requires that you have marked at least one movie as favorite else this test will fail
|
||||
Assert.IsTrue(tvShow.Id > 0);
|
||||
Assert.IsNotNull(tvShow.Name);
|
||||
Assert.IsNotNull(tvShow.PosterPath);
|
||||
Assert.IsNotNull(tvShow.BackdropPath);
|
||||
Assert.IsNotNull(tvShow.OriginalName);
|
||||
Assert.IsNotNull(tvShow.Overview);
|
||||
Assert.IsNotNull(tvShow.OriginalLanguage);
|
||||
Assert.IsNotNull(tvShow.FirstAirDate);
|
||||
Assert.IsTrue(tvShow.VoteCount > 0);
|
||||
Assert.IsTrue(tvShow.VoteAverage > 0);
|
||||
Assert.IsTrue(tvShow.Popularity > 0);
|
||||
Assert.True(tvShow.Id > 0);
|
||||
Assert.NotNull(tvShow.Name);
|
||||
Assert.NotNull(tvShow.PosterPath);
|
||||
Assert.NotNull(tvShow.BackdropPath);
|
||||
Assert.NotNull(tvShow.OriginalName);
|
||||
Assert.NotNull(tvShow.Overview);
|
||||
Assert.NotNull(tvShow.OriginalLanguage);
|
||||
Assert.NotNull(tvShow.FirstAirDate);
|
||||
Assert.True(tvShow.VoteCount > 0);
|
||||
Assert.True(tvShow.VoteAverage > 0);
|
||||
Assert.True(tvShow.Popularity > 0);
|
||||
|
||||
Assert.IsNotNull(tvShow.GenreIds);
|
||||
Assert.IsTrue(tvShow.GenreIds.Any());
|
||||
Assert.NotNull(tvShow.GenreIds);
|
||||
Assert.True(tvShow.GenreIds.Any());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestAccountGetMovieWatchlist()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
TestHelpers.SearchPages(i => _config.Client.AccountGetFavoriteMoviesAsync(i).Result);
|
||||
SearchMovie movie = _config.Client.AccountGetFavoriteMoviesAsync().Result.Results[0];
|
||||
SearchMovie movie = _config.Client.AccountGetFavoriteMoviesAsync().Sync().Results[0];
|
||||
|
||||
// Requires that you have added at least one movie to your watchlist else this test will fail
|
||||
Assert.IsTrue(movie.Id > 0);
|
||||
Assert.IsNotNull(movie.Title);
|
||||
Assert.IsNotNull(movie.PosterPath);
|
||||
Assert.IsNotNull(movie.BackdropPath);
|
||||
Assert.IsNotNull(movie.OriginalTitle);
|
||||
Assert.IsNotNull(movie.Overview);
|
||||
Assert.IsNotNull(movie.OriginalLanguage);
|
||||
Assert.IsNotNull(movie.ReleaseDate);
|
||||
Assert.IsTrue(movie.VoteCount > 0);
|
||||
Assert.IsTrue(movie.VoteAverage > 0);
|
||||
Assert.IsTrue(movie.Popularity > 0);
|
||||
Assert.True(movie.Id > 0);
|
||||
Assert.NotNull(movie.Title);
|
||||
Assert.NotNull(movie.PosterPath);
|
||||
Assert.NotNull(movie.BackdropPath);
|
||||
Assert.NotNull(movie.OriginalTitle);
|
||||
Assert.NotNull(movie.Overview);
|
||||
Assert.NotNull(movie.OriginalLanguage);
|
||||
Assert.NotNull(movie.ReleaseDate);
|
||||
Assert.True(movie.VoteCount > 0);
|
||||
Assert.True(movie.VoteAverage > 0);
|
||||
Assert.True(movie.Popularity > 0);
|
||||
|
||||
Assert.IsNotNull(movie.GenreIds);
|
||||
Assert.IsTrue(movie.GenreIds.Any());
|
||||
Assert.NotNull(movie.GenreIds);
|
||||
Assert.True(movie.GenreIds.Any());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestAccountGetTvWatchlist()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
TestHelpers.SearchPages(i => _config.Client.AccountGetTvWatchlistAsync(i).Result);
|
||||
SearchTv tvShow = _config.Client.AccountGetTvWatchlistAsync().Result.Results[0];
|
||||
SearchTv tvShow = _config.Client.AccountGetTvWatchlistAsync().Sync().Results[0];
|
||||
|
||||
// Requires that you have added at least one movie to your watchlist else this test will fail
|
||||
Assert.IsTrue(tvShow.Id > 0);
|
||||
Assert.IsNotNull(tvShow.Name);
|
||||
Assert.IsNotNull(tvShow.PosterPath);
|
||||
Assert.IsNotNull(tvShow.BackdropPath);
|
||||
Assert.IsNotNull(tvShow.OriginalName);
|
||||
Assert.IsNotNull(tvShow.Overview);
|
||||
Assert.IsNotNull(tvShow.OriginalLanguage);
|
||||
Assert.IsNotNull(tvShow.FirstAirDate);
|
||||
Assert.IsTrue(tvShow.VoteCount > 0);
|
||||
Assert.IsTrue(tvShow.VoteAverage > 0);
|
||||
Assert.IsTrue(tvShow.Popularity > 0);
|
||||
Assert.True(tvShow.Id > 0);
|
||||
Assert.NotNull(tvShow.Name);
|
||||
Assert.NotNull(tvShow.PosterPath);
|
||||
Assert.NotNull(tvShow.BackdropPath);
|
||||
Assert.NotNull(tvShow.OriginalName);
|
||||
Assert.NotNull(tvShow.Overview);
|
||||
Assert.NotNull(tvShow.OriginalLanguage);
|
||||
Assert.NotNull(tvShow.FirstAirDate);
|
||||
Assert.True(tvShow.VoteCount > 0);
|
||||
Assert.True(tvShow.VoteAverage > 0);
|
||||
Assert.True(tvShow.Popularity > 0);
|
||||
|
||||
Assert.IsNotNull(tvShow.GenreIds);
|
||||
Assert.IsTrue(tvShow.GenreIds.Any());
|
||||
Assert.NotNull(tvShow.GenreIds);
|
||||
Assert.True(tvShow.GenreIds.Any());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestAccountGetRatedMovies()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
TestHelpers.SearchPages(i => _config.Client.AccountGetFavoriteMoviesAsync(i).Result);
|
||||
SearchMovie movie = _config.Client.AccountGetFavoriteMoviesAsync().Result.Results[0];
|
||||
SearchMovie movie = _config.Client.AccountGetFavoriteMoviesAsync().Sync().Results[0];
|
||||
|
||||
// Requires that you have rated at least one movie else this test will fail
|
||||
Assert.IsTrue(movie.Id > 0);
|
||||
Assert.IsNotNull(movie.Title);
|
||||
Assert.IsNotNull(movie.PosterPath);
|
||||
Assert.IsNotNull(movie.BackdropPath);
|
||||
Assert.IsNotNull(movie.OriginalTitle);
|
||||
Assert.IsNotNull(movie.Overview);
|
||||
Assert.IsNotNull(movie.OriginalLanguage);
|
||||
Assert.IsNotNull(movie.ReleaseDate);
|
||||
Assert.IsTrue(movie.VoteCount > 0);
|
||||
Assert.IsTrue(movie.VoteAverage > 0);
|
||||
Assert.IsTrue(movie.Popularity > 0);
|
||||
Assert.True(movie.Id > 0);
|
||||
Assert.NotNull(movie.Title);
|
||||
Assert.NotNull(movie.PosterPath);
|
||||
Assert.NotNull(movie.BackdropPath);
|
||||
Assert.NotNull(movie.OriginalTitle);
|
||||
Assert.NotNull(movie.Overview);
|
||||
Assert.NotNull(movie.OriginalLanguage);
|
||||
Assert.NotNull(movie.ReleaseDate);
|
||||
Assert.True(movie.VoteCount > 0);
|
||||
Assert.True(movie.VoteAverage > 0);
|
||||
Assert.True(movie.Popularity > 0);
|
||||
|
||||
Assert.IsNotNull(movie.GenreIds);
|
||||
Assert.IsTrue(movie.GenreIds.Any());
|
||||
Assert.NotNull(movie.GenreIds);
|
||||
Assert.True(movie.GenreIds.Any());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestAccountGetRatedTv()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
TestHelpers.SearchPages(i => _config.Client.AccountGetRatedTvShowsAsync(i).Result);
|
||||
SearchTv tvShow = _config.Client.AccountGetRatedTvShowsAsync().Result.Results[0];
|
||||
SearchTv tvShow = _config.Client.AccountGetRatedTvShowsAsync().Sync().Results[0];
|
||||
|
||||
// Requires that you have rated at least one movie else this test will fail
|
||||
Assert.IsTrue(tvShow.Id > 0);
|
||||
Assert.IsNotNull(tvShow.Name);
|
||||
Assert.IsNotNull(tvShow.PosterPath);
|
||||
Assert.IsNotNull(tvShow.BackdropPath);
|
||||
Assert.IsNotNull(tvShow.OriginalName);
|
||||
Assert.IsNotNull(tvShow.Overview);
|
||||
Assert.IsNotNull(tvShow.OriginalLanguage);
|
||||
Assert.IsNotNull(tvShow.FirstAirDate);
|
||||
Assert.IsTrue(tvShow.VoteCount > 0);
|
||||
Assert.IsTrue(tvShow.VoteAverage > 0);
|
||||
Assert.IsTrue(tvShow.Popularity > 0);
|
||||
Assert.True(tvShow.Id > 0);
|
||||
Assert.NotNull(tvShow.Name);
|
||||
Assert.NotNull(tvShow.PosterPath);
|
||||
Assert.NotNull(tvShow.BackdropPath);
|
||||
Assert.NotNull(tvShow.OriginalName);
|
||||
Assert.NotNull(tvShow.Overview);
|
||||
Assert.NotNull(tvShow.OriginalLanguage);
|
||||
Assert.NotNull(tvShow.FirstAirDate);
|
||||
Assert.True(tvShow.VoteCount > 0);
|
||||
Assert.True(tvShow.VoteAverage > 0);
|
||||
Assert.True(tvShow.Popularity > 0);
|
||||
|
||||
Assert.IsNotNull(tvShow.GenreIds);
|
||||
Assert.IsTrue(tvShow.GenreIds.Any());
|
||||
Assert.NotNull(tvShow.GenreIds);
|
||||
Assert.True(tvShow.GenreIds.Any());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestAccountGetRatedTvEpisodes()
|
||||
{
|
||||
// TODO: Error in TMDb: https://www.themoviedb.org/talk/557f1af49251410a2c002480
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
TestHelpers.SearchPages(i => _config.Client.AccountGetRatedTvShowEpisodesAsync(i).Result);
|
||||
SearchTvEpisode tvEpisode = _config.Client.AccountGetRatedTvShowEpisodesAsync().Result.Results[0];
|
||||
|
||||
SearchTvEpisode tvEpisode = _config.Client.AccountGetRatedTvShowEpisodesAsync().Sync().Results[0];
|
||||
|
||||
// Requires that you have rated at least one movie else this test will fail
|
||||
Assert.IsTrue(tvEpisode.Id > 0);
|
||||
Assert.IsTrue(tvEpisode.ShowId > 0);
|
||||
Assert.IsTrue(tvEpisode.EpisodeNumber > 0);
|
||||
Assert.IsTrue(tvEpisode.SeasonNumber > 0);
|
||||
Assert.IsNotNull(tvEpisode.AirDate);
|
||||
Assert.IsNotNull(tvEpisode.StillPath);
|
||||
Assert.IsTrue(tvEpisode.VoteCount > 0);
|
||||
Assert.IsTrue(tvEpisode.VoteAverage > 0);
|
||||
Assert.IsTrue(tvEpisode.Rating > 0);
|
||||
Assert.True(tvEpisode.Id > 0);
|
||||
Assert.True(tvEpisode.ShowId > 0);
|
||||
Assert.True(tvEpisode.EpisodeNumber > 0);
|
||||
Assert.True(tvEpisode.SeasonNumber > 0);
|
||||
Assert.NotNull(tvEpisode.AirDate);
|
||||
Assert.NotNull(tvEpisode.StillPath);
|
||||
Assert.True(tvEpisode.VoteCount > 0);
|
||||
Assert.True(tvEpisode.VoteAverage > 0);
|
||||
Assert.True(tvEpisode.Rating > 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestAccountChangeTvFavoriteStatus()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Ensure that the test movie is not marked as favorite before we start the test
|
||||
if (DoesFavoriteListContainSpecificTvShow(IdHelper.DoctorWho))
|
||||
Assert.Fail("Test tv show '{0}' was already marked as favorite. Unable to perform test correctly", IdHelper.DoctorWho);
|
||||
throw new Exception("Test tv show '{IdHelper.DoctorWho}' was already marked as favorite. Unable to perform test correctly");
|
||||
|
||||
// Try to mark is as a favorite
|
||||
Assert.IsTrue(_config.Client.AccountChangeFavoriteStatusAsync(MediaType.TVShow, IdHelper.DoctorWho, true).Result);
|
||||
Assert.True(_config.Client.AccountChangeFavoriteStatusAsync(MediaType.TVShow, IdHelper.DoctorWho, true).Result);
|
||||
|
||||
// Check if it worked
|
||||
Assert.IsTrue(DoesFavoriteListContainSpecificTvShow(IdHelper.DoctorWho));
|
||||
Assert.True(DoesFavoriteListContainSpecificTvShow(IdHelper.DoctorWho));
|
||||
|
||||
// Try to un-mark is as a favorite
|
||||
Assert.IsTrue(_config.Client.AccountChangeFavoriteStatusAsync(MediaType.TVShow, IdHelper.DoctorWho, false).Result);
|
||||
Assert.True(_config.Client.AccountChangeFavoriteStatusAsync(MediaType.TVShow, IdHelper.DoctorWho, false).Result);
|
||||
|
||||
// Check if it worked
|
||||
Assert.IsFalse(DoesFavoriteListContainSpecificTvShow(IdHelper.DoctorWho));
|
||||
Assert.False(DoesFavoriteListContainSpecificTvShow(IdHelper.DoctorWho));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestAccountChangeMovieFavoriteStatus()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Ensure that the test movie is not marked as favorite before we start the test
|
||||
if (DoesFavoriteListContainSpecificMovie(IdHelper.Terminator))
|
||||
Assert.Fail("Test movie '{0}' was already marked as favorite. Unable to perform test correctly", IdHelper.Terminator);
|
||||
throw new Exception("Test movie '{IdHelper.Terminator}' was already marked as favorite. Unable to perform test correctly");
|
||||
|
||||
// Try to mark is as a favorite
|
||||
Assert.IsTrue(_config.Client.AccountChangeFavoriteStatusAsync(MediaType.Movie, IdHelper.Terminator, true).Result);
|
||||
Assert.True(_config.Client.AccountChangeFavoriteStatusAsync(MediaType.Movie, IdHelper.Terminator, true).Result);
|
||||
|
||||
// Check if it worked
|
||||
Assert.IsTrue(DoesFavoriteListContainSpecificMovie(IdHelper.Terminator));
|
||||
Assert.True(DoesFavoriteListContainSpecificMovie(IdHelper.Terminator));
|
||||
|
||||
// Try to un-mark is as a favorite
|
||||
Assert.IsTrue(_config.Client.AccountChangeFavoriteStatusAsync(MediaType.Movie, IdHelper.Terminator, false).Result);
|
||||
Assert.True(_config.Client.AccountChangeFavoriteStatusAsync(MediaType.Movie, IdHelper.Terminator, false).Result);
|
||||
|
||||
// Check if it worked
|
||||
Assert.IsFalse(DoesFavoriteListContainSpecificMovie(IdHelper.Terminator));
|
||||
Assert.False(DoesFavoriteListContainSpecificMovie(IdHelper.Terminator));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestAccountChangeTvWatchlistStatus()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Ensure that the test movie is not marked as favorite before we start the test
|
||||
if (DoesWatchListContainSpecificTvShow(IdHelper.DoctorWho))
|
||||
Assert.Fail("Test tv show '{0}' was already on watchlist. Unable to perform test correctly", IdHelper.DoctorWho);
|
||||
throw new Exception("Test tv show '{IdHelper.DoctorWho}' was already on watchlist. Unable to perform test correctly");
|
||||
|
||||
// Try to add an item to the watchlist
|
||||
Assert.IsTrue(_config.Client.AccountChangeWatchlistStatusAsync(MediaType.TVShow, IdHelper.DoctorWho, true).Result);
|
||||
Assert.True(_config.Client.AccountChangeWatchlistStatusAsync(MediaType.TVShow, IdHelper.DoctorWho, true).Result);
|
||||
|
||||
// Check if it worked
|
||||
Assert.IsTrue(DoesWatchListContainSpecificTvShow(IdHelper.DoctorWho));
|
||||
Assert.True(DoesWatchListContainSpecificTvShow(IdHelper.DoctorWho));
|
||||
|
||||
// Try to remove item from watchlist
|
||||
Assert.IsTrue(_config.Client.AccountChangeWatchlistStatusAsync(MediaType.TVShow, IdHelper.DoctorWho, false).Result);
|
||||
Assert.True(_config.Client.AccountChangeWatchlistStatusAsync(MediaType.TVShow, IdHelper.DoctorWho, false).Result);
|
||||
|
||||
// Check if it worked
|
||||
Assert.IsFalse(DoesWatchListContainSpecificTvShow(IdHelper.DoctorWho));
|
||||
Assert.False(DoesWatchListContainSpecificTvShow(IdHelper.DoctorWho));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestAccountChangeMovieWatchlistStatus()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Ensure that the test movie is not marked as favorite before we start the test
|
||||
if (DoesWatchListContainSpecificMovie(IdHelper.Terminator))
|
||||
Assert.Fail("Test movie '{0}' was already on watchlist. Unable to perform test correctly", IdHelper.Terminator);
|
||||
throw new Exception("Test movie '{IdHelper.Terminator}' was already on watchlist. Unable to perform test correctly");
|
||||
|
||||
// Try to add an item to the watchlist
|
||||
Assert.IsTrue(_config.Client.AccountChangeWatchlistStatusAsync(MediaType.Movie, IdHelper.Terminator, true).Result);
|
||||
Assert.True(_config.Client.AccountChangeWatchlistStatusAsync(MediaType.Movie, IdHelper.Terminator, true).Result);
|
||||
|
||||
// Check if it worked
|
||||
Assert.IsTrue(DoesWatchListContainSpecificMovie(IdHelper.Terminator));
|
||||
Assert.True(DoesWatchListContainSpecificMovie(IdHelper.Terminator));
|
||||
|
||||
// Try to remove item from watchlist
|
||||
Assert.IsTrue(_config.Client.AccountChangeWatchlistStatusAsync(MediaType.Movie, IdHelper.Terminator, false).Result);
|
||||
Assert.True(_config.Client.AccountChangeWatchlistStatusAsync(MediaType.Movie, IdHelper.Terminator, false).Result);
|
||||
|
||||
// Check if it worked
|
||||
Assert.IsFalse(DoesWatchListContainSpecificMovie(IdHelper.Terminator));
|
||||
Assert.False(DoesWatchListContainSpecificMovie(IdHelper.Terminator));
|
||||
}
|
||||
|
||||
private bool DoesFavoriteListContainSpecificTvShow(int tvId)
|
||||
|
@ -1,7 +1,8 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using TMDbLibTests.Exceptions;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
using TMDbLibTests.Helpers;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
|
||||
namespace TMDbLibTests
|
||||
@ -9,35 +10,28 @@ namespace TMDbLibTests
|
||||
/// <summary>
|
||||
/// https://www.themoviedb.org/documentation/api/sessions
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class ClientAuthenticationTests : TestBase
|
||||
{
|
||||
private TestConfig _config;
|
||||
private readonly TestConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public override void Initiator()
|
||||
public ClientAuthenticationTests()
|
||||
{
|
||||
base.Initiator();
|
||||
|
||||
_config = new TestConfig();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(_config.Username) || string.IsNullOrWhiteSpace(_config.Password))
|
||||
throw new ConfigurationErrorsException("You need to provide a username and password or some tests won't be able to execute.");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestAuthenticationRequestNewToken()
|
||||
{
|
||||
Token token = _config.Client.AuthenticationRequestAutenticationTokenAsync().Result;
|
||||
Token token = _config.Client.AuthenticationRequestAutenticationTokenAsync().Sync();
|
||||
|
||||
Assert.IsNotNull(token);
|
||||
Assert.IsTrue(token.Success);
|
||||
Assert.IsNotNull(token.AuthenticationCallback);
|
||||
Assert.IsNotNull(token.ExpiresAt);
|
||||
Assert.IsNotNull(token.RequestToken);
|
||||
Assert.NotNull(token);
|
||||
Assert.True(token.Success);
|
||||
Assert.NotNull(token.AuthenticationCallback);
|
||||
Assert.NotNull(token.ExpiresAt);
|
||||
Assert.NotNull(token.RequestToken);
|
||||
}
|
||||
|
||||
//<remarks>
|
||||
@ -47,106 +41,74 @@ namespace TMDbLibTests
|
||||
//Log-in to a TMDb account and grant access when requested.
|
||||
//Use the RequestToken string previously provided as value for this test
|
||||
//</remarks>
|
||||
//[TestMethod]
|
||||
//[Fact]
|
||||
//public void TestAuthenticationUserAuthenticatedSessionSuccess()
|
||||
//{
|
||||
// const string requestToken = "cb49e29af0473e78a4a489c91c6a8259407a343b";
|
||||
// UserSession session = _config.Client.AuthenticationGetUserSessionAsync(requestToken);
|
||||
|
||||
// Assert.IsNotNull(session);
|
||||
// Assert.IsTrue(session.Success);
|
||||
// Assert.IsNotNull(session.SessionId);
|
||||
// Assert.NotNull(session);
|
||||
// Assert.True(session.Success);
|
||||
// Assert.NotNull(session.SessionId);
|
||||
//}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(UnauthorizedAccessException))]
|
||||
[Fact]
|
||||
public void TestAuthenticationUserAuthenticatedSessionInvalidToken()
|
||||
{
|
||||
const string requestToken = "bla";
|
||||
|
||||
try
|
||||
{
|
||||
_config.Client.AuthenticationGetUserSessionAsync(requestToken).Wait();
|
||||
}
|
||||
catch (AggregateException ex)
|
||||
{
|
||||
throw ex.InnerException;
|
||||
}
|
||||
|
||||
// Should always throw exception
|
||||
Assert.Fail();
|
||||
Assert.Throws<UnauthorizedAccessException>(() => _config.Client.AuthenticationGetUserSessionAsync(requestToken).Sync());
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// Requires a valid test user to be assigned
|
||||
/// </remarks>
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestAuthenticationGetUserSessionApiUserValidationSuccess()
|
||||
{
|
||||
Token token = _config.Client.AuthenticationRequestAutenticationTokenAsync().Result;
|
||||
Token token = _config.Client.AuthenticationRequestAutenticationTokenAsync().Sync();
|
||||
|
||||
_config.Client.AuthenticationValidateUserTokenAsync(token.RequestToken, _config.Username, _config.Password).Wait();
|
||||
_config.Client.AuthenticationValidateUserTokenAsync(token.RequestToken, _config.Username, _config.Password).Sync();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(UnauthorizedAccessException))]
|
||||
[Fact]
|
||||
public void TestAuthenticationGetUserSessionApiUserValidationInvalidLogin()
|
||||
{
|
||||
Token token = _config.Client.AuthenticationRequestAutenticationTokenAsync().Result;
|
||||
Token token = _config.Client.AuthenticationRequestAutenticationTokenAsync().Sync();
|
||||
|
||||
try
|
||||
{
|
||||
_config.Client.AuthenticationValidateUserTokenAsync(token.RequestToken, "bla", "bla").Wait();
|
||||
}
|
||||
catch (AggregateException ex)
|
||||
{
|
||||
throw ex.InnerException;
|
||||
}
|
||||
|
||||
// Should always throw exception
|
||||
Assert.Fail();
|
||||
Assert.Throws<UnauthorizedAccessException>(() => _config.Client.AuthenticationValidateUserTokenAsync(token.RequestToken, "bla", "bla").Sync());
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// Requires a valid test user to be assigned
|
||||
/// </remarks>
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void AuthenticationGetUserSessionWithLoginSuccess()
|
||||
{
|
||||
UserSession session = _config.Client.AuthenticationGetUserSessionAsync(_config.Username, _config.Password).Result;
|
||||
|
||||
Assert.IsNotNull(session);
|
||||
Assert.IsTrue(session.Success);
|
||||
Assert.IsNotNull(session.SessionId);
|
||||
Assert.NotNull(session);
|
||||
Assert.True(session.Success);
|
||||
Assert.NotNull(session.SessionId);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(UnauthorizedAccessException))]
|
||||
[Fact]
|
||||
public void TestAuthenticationUserAuthenticatedSessionOldToken()
|
||||
{
|
||||
const string requestToken = "5f3a62c0d7977319e3d14adf1a2064c0c0938bcf";
|
||||
try
|
||||
{
|
||||
_config.Client.AuthenticationGetUserSessionAsync(requestToken).Wait();
|
||||
}
|
||||
catch (AggregateException ex)
|
||||
{
|
||||
throw ex.InnerException;
|
||||
}
|
||||
|
||||
// Should always throw exception
|
||||
Assert.Fail();
|
||||
Assert.Throws<UnauthorizedAccessException>(() => _config.Client.AuthenticationGetUserSessionAsync(requestToken).Sync());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestAuthenticationCreateGuestSession()
|
||||
{
|
||||
GuestSession guestSession = _config.Client.AuthenticationCreateGuestSessionAsync().Result;
|
||||
GuestSession guestSession = _config.Client.AuthenticationCreateGuestSessionAsync().Sync();
|
||||
|
||||
Assert.IsNotNull(guestSession);
|
||||
Assert.IsTrue(guestSession.Success);
|
||||
Assert.IsNotNull(guestSession.ExpiresAt);
|
||||
Assert.IsNotNull(guestSession.GuestSessionId);
|
||||
Assert.NotNull(guestSession);
|
||||
Assert.True(guestSession.Success);
|
||||
Assert.NotNull(guestSession.ExpiresAt);
|
||||
Assert.NotNull(guestSession.GuestSessionId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,65 +1,59 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Certifications;
|
||||
using TMDbLibTests.Helpers;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientCertificationsTests : TestBase
|
||||
{
|
||||
private TestConfig _config;
|
||||
private readonly TestConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public override void Initiator()
|
||||
public ClientCertificationsTests()
|
||||
{
|
||||
base.Initiator();
|
||||
|
||||
_config = new TestConfig();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestCertificationsListMovie()
|
||||
{
|
||||
CertificationsContainer result = _config.Client.GetMovieCertificationsAsync().Result;
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsNotNull(result.Certifications);
|
||||
Assert.IsTrue(result.Certifications.Count > 1);
|
||||
CertificationsContainer result = _config.Client.GetMovieCertificationsAsync().Sync();
|
||||
Assert.NotNull(result);
|
||||
Assert.NotNull(result.Certifications);
|
||||
Assert.True(result.Certifications.Count > 1);
|
||||
|
||||
List<CertificationItem> certAu = result.Certifications["AU"];
|
||||
Assert.IsNotNull(certAu);
|
||||
Assert.IsTrue(certAu.Count > 2);
|
||||
Assert.NotNull(certAu);
|
||||
Assert.True(certAu.Count > 2);
|
||||
|
||||
CertificationItem ratingE = certAu.Single(s => s.Certification == "E");
|
||||
|
||||
Assert.IsNotNull(ratingE);
|
||||
Assert.AreEqual("E", ratingE.Certification);
|
||||
Assert.AreEqual("Exempt from classification. Films that are exempt from classification must not contain contentious material (i.e. material that would ordinarily be rated M or higher).", ratingE.Meaning);
|
||||
Assert.AreEqual(1, ratingE.Order);
|
||||
Assert.NotNull(ratingE);
|
||||
Assert.Equal("E", ratingE.Certification);
|
||||
Assert.Equal("Exempt from classification. Films that are exempt from classification must not contain contentious material (i.e. material that would ordinarily be rated M or higher).", ratingE.Meaning);
|
||||
Assert.Equal(1, ratingE.Order);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestCertificationsListTv()
|
||||
{
|
||||
CertificationsContainer result = _config.Client.GetTvCertificationsAsync().Result;
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsNotNull(result.Certifications);
|
||||
Assert.IsTrue(result.Certifications.Count > 1);
|
||||
CertificationsContainer result = _config.Client.GetTvCertificationsAsync().Sync();
|
||||
Assert.NotNull(result);
|
||||
Assert.NotNull(result.Certifications);
|
||||
Assert.True(result.Certifications.Count > 1);
|
||||
|
||||
List<CertificationItem> certUs = result.Certifications["US"];
|
||||
Assert.IsNotNull(certUs);
|
||||
Assert.IsTrue(certUs.Count > 2);
|
||||
Assert.NotNull(certUs);
|
||||
Assert.True(certUs.Count > 2);
|
||||
|
||||
CertificationItem ratingNr = certUs.SingleOrDefault(s => s.Certification == "NR");
|
||||
|
||||
Assert.IsNotNull(ratingNr);
|
||||
Assert.AreEqual("NR", ratingNr.Certification);
|
||||
Assert.AreEqual("No rating information.", ratingNr.Meaning);
|
||||
Assert.AreEqual(0, ratingNr.Order);
|
||||
Assert.NotNull(ratingNr);
|
||||
Assert.Equal("NR", ratingNr.Certification);
|
||||
Assert.Equal("No rating information.", ratingNr.Meaning);
|
||||
Assert.Equal(0, ratingNr.Order);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,152 +1,146 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Changes;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLibTests.Helpers;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientChangesTests : TestBase
|
||||
{
|
||||
private TestConfig _config;
|
||||
private readonly TestConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public override void Initiator()
|
||||
public ClientChangesTests()
|
||||
{
|
||||
base.Initiator();
|
||||
|
||||
_config = new TestConfig();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestChangesMovies()
|
||||
{
|
||||
// Basic check
|
||||
SearchContainer<ChangesListItem> changesPage1 = _config.Client.GetChangesMoviesAsync().Result;
|
||||
SearchContainer<ChangesListItem> changesPage1 = _config.Client.GetChangesMoviesAsync().Sync();
|
||||
|
||||
Assert.IsNotNull(changesPage1);
|
||||
Assert.IsTrue(changesPage1.Results.Count > 0);
|
||||
Assert.IsTrue(changesPage1.TotalResults > changesPage1.Results.Count);
|
||||
Assert.AreEqual(1, changesPage1.Page);
|
||||
Assert.NotNull(changesPage1);
|
||||
Assert.True(changesPage1.Results.Count > 0);
|
||||
Assert.True(changesPage1.TotalResults > changesPage1.Results.Count);
|
||||
Assert.Equal(1, changesPage1.Page);
|
||||
|
||||
// Page 2
|
||||
SearchContainer<ChangesListItem> changesPage2 = _config.Client.GetChangesMoviesAsync(2).Result;
|
||||
|
||||
Assert.IsNotNull(changesPage2);
|
||||
Assert.AreEqual(2, changesPage2.Page);
|
||||
Assert.NotNull(changesPage2);
|
||||
Assert.Equal(2, changesPage2.Page);
|
||||
|
||||
// Check date range (max)
|
||||
DateTime higher = DateTime.UtcNow.AddDays(-7);
|
||||
SearchContainer<ChangesListItem> changesMaxDate = _config.Client.GetChangesMoviesAsync(endDate: higher).Result;
|
||||
|
||||
Assert.IsNotNull(changesMaxDate);
|
||||
Assert.AreEqual(1, changesMaxDate.Page);
|
||||
Assert.AreNotEqual(changesPage1.TotalResults, changesMaxDate.TotalResults);
|
||||
Assert.NotNull(changesMaxDate);
|
||||
Assert.Equal(1, changesMaxDate.Page);
|
||||
Assert.NotEqual(changesPage1.TotalResults, changesMaxDate.TotalResults);
|
||||
|
||||
// Check date range (lower)
|
||||
DateTime lower = DateTime.UtcNow.AddDays(-6); // Use 6 days to avoid clashes with the 'higher'
|
||||
SearchContainer<ChangesListItem> changesLowDate = _config.Client.GetChangesMoviesAsync(startDate: lower).Result;
|
||||
|
||||
Assert.IsNotNull(changesLowDate);
|
||||
Assert.AreEqual(1, changesLowDate.Page);
|
||||
Assert.AreNotEqual(changesPage1.TotalResults, changesLowDate.TotalResults);
|
||||
Assert.NotNull(changesLowDate);
|
||||
Assert.Equal(1, changesLowDate.Page);
|
||||
Assert.NotEqual(changesPage1.TotalResults, changesLowDate.TotalResults);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestChangesPeople()
|
||||
{
|
||||
// Basic check
|
||||
SearchContainer<ChangesListItem> changesPage1 = _config.Client.GetChangesPeopleAsync().Result;
|
||||
SearchContainer<ChangesListItem> changesPage1 = _config.Client.GetChangesPeopleAsync().Sync();
|
||||
|
||||
Assert.IsNotNull(changesPage1);
|
||||
Assert.IsTrue(changesPage1.Results.Count > 0);
|
||||
Assert.IsTrue(changesPage1.TotalResults > changesPage1.Results.Count);
|
||||
Assert.AreEqual(1, changesPage1.Page);
|
||||
Assert.NotNull(changesPage1);
|
||||
Assert.True(changesPage1.Results.Count > 0);
|
||||
Assert.True(changesPage1.TotalResults > changesPage1.Results.Count);
|
||||
Assert.Equal(1, changesPage1.Page);
|
||||
|
||||
// Page 2
|
||||
SearchContainer<ChangesListItem> changesPage2 = _config.Client.GetChangesPeopleAsync(2).Result;
|
||||
|
||||
Assert.IsNotNull(changesPage2);
|
||||
Assert.AreEqual(2, changesPage2.Page);
|
||||
Assert.NotNull(changesPage2);
|
||||
Assert.Equal(2, changesPage2.Page);
|
||||
|
||||
// Check date range (max)
|
||||
DateTime higher = DateTime.UtcNow.AddDays(-7);
|
||||
SearchContainer<ChangesListItem> changesMaxDate = _config.Client.GetChangesPeopleAsync(endDate: higher).Result;
|
||||
|
||||
Assert.IsNotNull(changesMaxDate);
|
||||
Assert.AreEqual(1, changesMaxDate.Page);
|
||||
Assert.AreNotEqual(changesPage1.TotalResults, changesMaxDate.TotalResults);
|
||||
Assert.NotNull(changesMaxDate);
|
||||
Assert.Equal(1, changesMaxDate.Page);
|
||||
Assert.NotEqual(changesPage1.TotalResults, changesMaxDate.TotalResults);
|
||||
|
||||
// Check date range (lower)
|
||||
DateTime lower = DateTime.UtcNow.AddDays(-6); // Use 6 days to avoid clashes with the 'higher'
|
||||
SearchContainer<ChangesListItem> changesLowDate = _config.Client.GetChangesPeopleAsync(startDate: lower).Result;
|
||||
|
||||
Assert.IsNotNull(changesLowDate);
|
||||
Assert.AreEqual(1, changesLowDate.Page);
|
||||
Assert.AreNotEqual(changesPage1.TotalResults, changesLowDate.TotalResults);
|
||||
Assert.NotNull(changesLowDate);
|
||||
Assert.Equal(1, changesLowDate.Page);
|
||||
Assert.NotEqual(changesPage1.TotalResults, changesLowDate.TotalResults);
|
||||
|
||||
// None of the id's in changesLowDate should exist in changesMaxDate, and vice versa
|
||||
Assert.IsTrue(changesLowDate.Results.All(lowItem => changesMaxDate.Results.All(maxItem => maxItem.Id != lowItem.Id)));
|
||||
Assert.IsTrue(changesMaxDate.Results.All(maxItem => changesLowDate.Results.All(lowItem => maxItem.Id != lowItem.Id)));
|
||||
Assert.True(changesLowDate.Results.All(lowItem => changesMaxDate.Results.All(maxItem => maxItem.Id != lowItem.Id)));
|
||||
Assert.True(changesMaxDate.Results.All(maxItem => changesLowDate.Results.All(lowItem => maxItem.Id != lowItem.Id)));
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestChangesTvShows()
|
||||
{
|
||||
// Basic check
|
||||
SearchContainer<ChangesListItem> changesPage1 = _config.Client.GetChangesTvAsync().Result;
|
||||
SearchContainer<ChangesListItem> changesPage1 = _config.Client.GetChangesTvAsync().Sync();
|
||||
|
||||
Assert.IsNotNull(changesPage1);
|
||||
Assert.IsNotNull(changesPage1.Results);
|
||||
Assert.IsTrue(changesPage1.Results.Count > 0);
|
||||
Assert.IsTrue(changesPage1.TotalResults >= changesPage1.Results.Count);
|
||||
Assert.AreEqual(1, changesPage1.Page);
|
||||
Assert.NotNull(changesPage1);
|
||||
Assert.NotNull(changesPage1.Results);
|
||||
Assert.True(changesPage1.Results.Count > 0);
|
||||
Assert.True(changesPage1.TotalResults >= changesPage1.Results.Count);
|
||||
Assert.Equal(1, changesPage1.Page);
|
||||
|
||||
if (changesPage1.TotalPages > 1)
|
||||
{
|
||||
Assert.IsTrue(changesPage1.TotalResults > changesPage1.Results.Count);
|
||||
Assert.True(changesPage1.TotalResults > changesPage1.Results.Count);
|
||||
// Page 2
|
||||
SearchContainer<ChangesListItem> changesPage2 = _config.Client.GetChangesTvAsync(2).Result;
|
||||
|
||||
Assert.IsNotNull(changesPage2);
|
||||
Assert.AreEqual(2, changesPage2.Page);
|
||||
Assert.NotNull(changesPage2);
|
||||
Assert.Equal(2, changesPage2.Page);
|
||||
}
|
||||
|
||||
// Check date range (max)
|
||||
DateTime higher = DateTime.UtcNow.AddDays(-8);
|
||||
SearchContainer<ChangesListItem> changesMaxDate = _config.Client.GetChangesTvAsync(endDate: higher).Result;
|
||||
|
||||
Assert.IsNotNull(changesMaxDate);
|
||||
Assert.AreEqual(1, changesMaxDate.Page);
|
||||
Assert.AreNotEqual(changesPage1.TotalResults, changesMaxDate.TotalResults);
|
||||
Assert.NotNull(changesMaxDate);
|
||||
Assert.Equal(1, changesMaxDate.Page);
|
||||
Assert.NotEqual(changesPage1.TotalResults, changesMaxDate.TotalResults);
|
||||
|
||||
// Check date range (lower)
|
||||
DateTime lower = DateTime.UtcNow.AddDays(-6); // Use 6 days to avoid clashes with the 'higher'
|
||||
SearchContainer<ChangesListItem> changesLowDate = _config.Client.GetChangesTvAsync(startDate: lower).Result;
|
||||
|
||||
Assert.IsNotNull(changesLowDate);
|
||||
Assert.AreEqual(1, changesLowDate.Page);
|
||||
Assert.AreNotEqual(changesPage1.TotalResults, changesLowDate.TotalResults);
|
||||
Assert.NotNull(changesLowDate);
|
||||
Assert.Equal(1, changesLowDate.Page);
|
||||
Assert.NotEqual(changesPage1.TotalResults, changesLowDate.TotalResults);
|
||||
|
||||
// None of the id's in changesLowDate should exist in changesMaxDate, and vice versa
|
||||
foreach (ChangesListItem changeItem in changesLowDate.Results)
|
||||
{
|
||||
bool existsInOtherList = changesMaxDate.Results.Any(x => x.Id == changeItem.Id);
|
||||
|
||||
Assert.IsFalse(existsInOtherList, "Item id " + changeItem.Id + " is duplicated");
|
||||
Assert.False(existsInOtherList, "Item id " + changeItem.Id + " is duplicated");
|
||||
}
|
||||
|
||||
foreach (ChangesListItem changeItem in changesMaxDate.Results)
|
||||
{
|
||||
bool existsInOtherList = changesLowDate.Results.Any(x => x.Id == changeItem.Id);
|
||||
|
||||
Assert.IsFalse(existsInOtherList, "Item id " + changeItem.Id + " is duplicated");
|
||||
Assert.False(existsInOtherList, "Item id " + changeItem.Id + " is duplicated");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Collections;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLibTests.Helpers;
|
||||
@ -9,34 +9,22 @@ using TMDbLibTests.JsonHelpers;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientCollectionTests : TestBase
|
||||
{
|
||||
private static Dictionary<CollectionMethods, Func<Collection, object>> _methods;
|
||||
private TestConfig _config;
|
||||
private readonly TestConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public override void Initiator()
|
||||
public ClientCollectionTests()
|
||||
{
|
||||
base.Initiator();
|
||||
|
||||
_config = new TestConfig();
|
||||
|
||||
_methods = new Dictionary<CollectionMethods, Func<Collection, object>>
|
||||
{
|
||||
[CollectionMethods.Images] = collection => collection.Images
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on test class initialization
|
||||
/// </summary>
|
||||
[ClassInitialize]
|
||||
public static void InitialInitiator(TestContext context)
|
||||
{
|
||||
_methods = new Dictionary<CollectionMethods, Func<Collection, object>>();
|
||||
_methods[CollectionMethods.Images] = collection => collection.Images;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestCollectionsExtrasNone()
|
||||
{
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
@ -45,19 +33,19 @@ namespace TMDbLibTests
|
||||
Collection collection = _config.Client.GetCollectionAsync(IdHelper.JamesBondCollection).Result;
|
||||
|
||||
// TODO: Test all properties
|
||||
Assert.IsNotNull(collection);
|
||||
Assert.AreEqual("James Bond Collection", collection.Name);
|
||||
Assert.IsNotNull(collection.Parts);
|
||||
Assert.IsTrue(collection.Parts.Count > 0);
|
||||
Assert.NotNull(collection);
|
||||
Assert.Equal("James Bond Collection", collection.Name);
|
||||
Assert.NotNull(collection.Parts);
|
||||
Assert.True(collection.Parts.Count > 0);
|
||||
|
||||
// Test all extras, ensure none of them exist
|
||||
foreach (Func<Collection, object> selector in _methods.Values)
|
||||
{
|
||||
Assert.IsNull(selector(collection));
|
||||
Assert.Null(selector(collection));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestCollectionsExtrasExclusive()
|
||||
{
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
@ -66,7 +54,7 @@ namespace TMDbLibTests
|
||||
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetCollectionAsync(id, extras).Result, IdHelper.JamesBondCollection);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestCollectionsExtrasAll()
|
||||
{
|
||||
CollectionMethods combinedEnum = _methods.Keys.Aggregate((methods, movieMethods) => methods | movieMethods);
|
||||
@ -75,7 +63,7 @@ namespace TMDbLibTests
|
||||
TestMethodsHelper.TestAllNotNull(_methods, item);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestCollectionsImages()
|
||||
{
|
||||
// Get config
|
||||
@ -84,7 +72,7 @@ namespace TMDbLibTests
|
||||
// Test image url generator
|
||||
ImagesWithId images = _config.Client.GetCollectionImagesAsync(IdHelper.JamesBondCollection).Result;
|
||||
|
||||
Assert.AreEqual(IdHelper.JamesBondCollection, images.Id);
|
||||
Assert.Equal(IdHelper.JamesBondCollection, images.Id);
|
||||
TestImagesHelpers.TestImages(_config, images);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Companies;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLibTests.Helpers;
|
||||
@ -9,34 +9,22 @@ using TMDbLibTests.JsonHelpers;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientCompanyTests : TestBase
|
||||
{
|
||||
private static Dictionary<CompanyMethods, Func<Company, object>> _methods;
|
||||
private TestConfig _config;
|
||||
private readonly TestConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public override void Initiator()
|
||||
public ClientCompanyTests()
|
||||
{
|
||||
base.Initiator();
|
||||
|
||||
_config = new TestConfig();
|
||||
|
||||
_methods = new Dictionary<CompanyMethods, Func<Company, object>>
|
||||
{
|
||||
[CompanyMethods.Movies] = company => company.Movies
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on test class initialization
|
||||
/// </summary>
|
||||
[ClassInitialize]
|
||||
public static void InitialInitiator(TestContext context)
|
||||
{
|
||||
_methods = new Dictionary<CompanyMethods, Func<Company, object>>();
|
||||
_methods[CompanyMethods.Movies] = company => company.Movies;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestCompaniesExtrasNone()
|
||||
{
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
@ -44,19 +32,19 @@ namespace TMDbLibTests
|
||||
|
||||
Company company = _config.Client.GetCompanyAsync(IdHelper.TwentiethCenturyFox).Result;
|
||||
|
||||
Assert.IsNotNull(company);
|
||||
Assert.NotNull(company);
|
||||
|
||||
// TODO: Test all properties
|
||||
Assert.AreEqual("20th Century Fox", company.Name);
|
||||
Assert.Equal("20th Century Fox", company.Name);
|
||||
|
||||
// Test all extras, ensure none of them exist
|
||||
foreach (Func<Company, object> selector in _methods.Values)
|
||||
{
|
||||
Assert.IsNull(selector(company));
|
||||
Assert.Null(selector(company));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestCompaniesExtrasExclusive()
|
||||
{
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
@ -65,7 +53,7 @@ namespace TMDbLibTests
|
||||
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetCompanyAsync(id, extras).Result, IdHelper.TwentiethCenturyFox);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestCompaniesExtrasAll()
|
||||
{
|
||||
CompanyMethods combinedEnum = _methods.Keys.Aggregate((methods, movieMethods) => methods | movieMethods);
|
||||
@ -74,7 +62,7 @@ namespace TMDbLibTests
|
||||
TestMethodsHelper.TestAllNotNull(_methods, item);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestCompaniesGetters()
|
||||
{
|
||||
//GetCompanyMoviesAsync(int id, string language, int page = -1)
|
||||
@ -82,27 +70,27 @@ namespace TMDbLibTests
|
||||
SearchContainerWithId<MovieResult> respPage2 = _config.Client.GetCompanyMoviesAsync(IdHelper.TwentiethCenturyFox, 2).Result;
|
||||
SearchContainerWithId<MovieResult> respItalian = _config.Client.GetCompanyMoviesAsync(IdHelper.TwentiethCenturyFox, "it").Result;
|
||||
|
||||
Assert.IsNotNull(resp);
|
||||
Assert.IsNotNull(respPage2);
|
||||
Assert.IsNotNull(respItalian);
|
||||
Assert.NotNull(resp);
|
||||
Assert.NotNull(respPage2);
|
||||
Assert.NotNull(respItalian);
|
||||
|
||||
Assert.IsTrue(resp.Results.Count > 0);
|
||||
Assert.IsTrue(respPage2.Results.Count > 0);
|
||||
Assert.IsTrue(respItalian.Results.Count > 0);
|
||||
Assert.True(resp.Results.Count > 0);
|
||||
Assert.True(respPage2.Results.Count > 0);
|
||||
Assert.True(respItalian.Results.Count > 0);
|
||||
|
||||
bool allTitlesIdentical = true;
|
||||
for (int index = 0; index < resp.Results.Count; index++)
|
||||
{
|
||||
Assert.AreEqual(resp.Results[index].Id, respItalian.Results[index].Id);
|
||||
Assert.Equal(resp.Results[index].Id, respItalian.Results[index].Id);
|
||||
|
||||
if (resp.Results[index].Title != respItalian.Results[index].Title)
|
||||
allTitlesIdentical = false;
|
||||
}
|
||||
|
||||
Assert.IsFalse(allTitlesIdentical);
|
||||
Assert.False(allTitlesIdentical);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestCompaniesImages()
|
||||
{
|
||||
// Get config
|
||||
@ -114,28 +102,28 @@ namespace TMDbLibTests
|
||||
Uri url = _config.Client.GetImageUrl("original", company.LogoPath);
|
||||
Uri urlSecure = _config.Client.GetImageUrl("original", company.LogoPath, true);
|
||||
|
||||
Assert.IsTrue(TestHelpers.InternetUriExists(url));
|
||||
Assert.IsTrue(TestHelpers.InternetUriExists(urlSecure));
|
||||
Assert.True(TestHelpers.InternetUriExists(url));
|
||||
Assert.True(TestHelpers.InternetUriExists(urlSecure));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestCompaniesFull()
|
||||
{
|
||||
Company company = _config.Client.GetCompanyAsync(IdHelper.ColumbiaPictures).Result;
|
||||
|
||||
Assert.IsNotNull(company);
|
||||
Assert.NotNull(company);
|
||||
|
||||
Assert.AreEqual(IdHelper.ColumbiaPictures, company.Id);
|
||||
Assert.AreEqual("Columbia Pictures Industries, Inc. (CPII) is an American film production and distribution company. Columbia Pictures now forms part of the Columbia TriStar Motion Picture Group, owned by Sony Pictures Entertainment, a subsidiary of the Japanese conglomerate Sony. It is one of the leading film companies in the world, a member of the so-called Big Six. It was one of the so-called Little Three among the eight major film studios of Hollywood's Golden Age.", company.Description);
|
||||
Assert.AreEqual("Culver City, California", company.Headquarters);
|
||||
Assert.AreEqual("http://www.sonypictures.com/", company.Homepage);
|
||||
Assert.AreEqual("/mjUSfXXUhMiLAA1Zq1TfStNSoLR.png", company.LogoPath);
|
||||
Assert.AreEqual("Columbia Pictures", company.Name);
|
||||
Assert.Equal(IdHelper.ColumbiaPictures, company.Id);
|
||||
Assert.Equal("Columbia Pictures Industries, Inc. (CPII) is an American film production and distribution company. Columbia Pictures now forms part of the Columbia TriStar Motion Picture Group, owned by Sony Pictures Entertainment, a subsidiary of the Japanese conglomerate Sony. It is one of the leading film companies in the world, a member of the so-called Big Six. It was one of the so-called Little Three among the eight major film studios of Hollywood's Golden Age.", company.Description);
|
||||
Assert.Equal("Culver City, California", company.Headquarters);
|
||||
Assert.Equal("http://www.sonypictures.com/", company.Homepage);
|
||||
Assert.Equal("/mjUSfXXUhMiLAA1Zq1TfStNSoLR.png", company.LogoPath);
|
||||
Assert.Equal("Columbia Pictures", company.Name);
|
||||
|
||||
Assert.IsNotNull(company.ParentCompany);
|
||||
Assert.AreEqual(5752, company.ParentCompany.Id);
|
||||
Assert.AreEqual("/sFg00KK0vVq3oqvkCxRQWApYB83.png", company.ParentCompany.LogoPath);
|
||||
Assert.AreEqual("Sony Pictures Entertainment", company.ParentCompany.Name);
|
||||
Assert.NotNull(company.ParentCompany);
|
||||
Assert.Equal(5752, company.ParentCompany.Id);
|
||||
Assert.Equal("/sFg00KK0vVq3oqvkCxRQWApYB83.png", company.ParentCompany.LogoPath);
|
||||
Assert.Equal("Sony Pictures Entertainment", company.ParentCompany.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,86 +1,79 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Credit;
|
||||
using TMDbLibTests.Helpers;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientCreditTests : TestBase
|
||||
{
|
||||
private TestConfig _config;
|
||||
private readonly TestConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public override void Initiator()
|
||||
public ClientCreditTests()
|
||||
{
|
||||
base.Initiator();
|
||||
|
||||
_config = new TestConfig();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestGetCreditBase()
|
||||
{
|
||||
Credit result = _config.Client.GetCreditsAsync(IdHelper.BruceWillisMiamiVice).Result;
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.AreEqual("cast", result.CreditType);
|
||||
Assert.AreEqual("Actors", result.Department);
|
||||
Assert.AreEqual("Actor", result.Job);
|
||||
Assert.AreEqual("tv", result.MediaType);
|
||||
Assert.AreEqual(IdHelper.BruceWillisMiamiVice, result.Id);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal("cast", result.CreditType);
|
||||
Assert.Equal("Actors", result.Department);
|
||||
Assert.Equal("Actor", result.Job);
|
||||
Assert.Equal("tv", result.MediaType);
|
||||
Assert.Equal(IdHelper.BruceWillisMiamiVice, result.Id);
|
||||
|
||||
Assert.IsNotNull(result.Person);
|
||||
Assert.AreEqual("Bruce Willis", result.Person.Name);
|
||||
Assert.AreEqual(62, result.Person.Id);
|
||||
Assert.NotNull(result.Person);
|
||||
Assert.Equal("Bruce Willis", result.Person.Name);
|
||||
Assert.Equal(62, result.Person.Id);
|
||||
|
||||
Assert.IsNotNull(result.Media);
|
||||
Assert.AreEqual(1908, result.Media.Id);
|
||||
Assert.AreEqual("Miami Vice", result.Media.Name);
|
||||
Assert.AreEqual("Miami Vice", result.Media.OriginalName);
|
||||
Assert.AreEqual("", result.Media.Character);
|
||||
Assert.NotNull(result.Media);
|
||||
Assert.Equal(1908, result.Media.Id);
|
||||
Assert.Equal("Miami Vice", result.Media.Name);
|
||||
Assert.Equal("Miami Vice", result.Media.OriginalName);
|
||||
Assert.Equal("", result.Media.Character);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestGetCreditEpisode()
|
||||
{
|
||||
Credit result = _config.Client.GetCreditsAsync(IdHelper.BruceWillisMiamiVice).Result;
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsNotNull(result.Media);
|
||||
Assert.IsNotNull(result.Media.Episodes);
|
||||
Assert.NotNull(result);
|
||||
Assert.NotNull(result.Media);
|
||||
Assert.NotNull(result.Media.Episodes);
|
||||
|
||||
CreditEpisode item = result.Media.Episodes.SingleOrDefault(s => s.Name == "No Exit");
|
||||
Assert.IsNotNull(item);
|
||||
Assert.NotNull(item);
|
||||
|
||||
Assert.AreEqual(new DateTime(1984, 11, 9), item.AirDate);
|
||||
Assert.AreEqual(8, item.EpisodeNumber);
|
||||
Assert.AreEqual("No Exit", item.Name);
|
||||
Assert.AreEqual("Crockett attempts to help an old flame free herself from a racketeer, then is framed for taking bribes. Martin Castillo becomes the squad's new Lieutenant.", item.Overview);
|
||||
Assert.AreEqual(1, item.SeasonNumber);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(item.StillPath), "item.StillPath was not a valid image path, was: " + item.StillPath);
|
||||
Assert.Equal(new DateTime(1984, 11, 9), item.AirDate);
|
||||
Assert.Equal(8, item.EpisodeNumber);
|
||||
Assert.Equal("No Exit", item.Name);
|
||||
Assert.Equal("Crockett attempts to help an old flame free herself from a racketeer, then is framed for taking bribes. Martin Castillo becomes the squad's new Lieutenant.", item.Overview);
|
||||
Assert.Equal(1, item.SeasonNumber);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.StillPath), "item.StillPath was not a valid image path, was: " + item.StillPath);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestGetCreditSeasons()
|
||||
{
|
||||
Credit result = _config.Client.GetCreditsAsync(IdHelper.HughLaurieHouse).Result;
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsNotNull(result.Media);
|
||||
Assert.IsNotNull(result.Media.Seasons);
|
||||
Assert.NotNull(result);
|
||||
Assert.NotNull(result.Media);
|
||||
Assert.NotNull(result.Media.Seasons);
|
||||
|
||||
CreditSeason item = result.Media.Seasons.SingleOrDefault(s => s.SeasonNumber == 1);
|
||||
Assert.IsNotNull(item);
|
||||
Assert.NotNull(item);
|
||||
|
||||
Assert.AreEqual(new DateTime(2004, 11, 16), item.AirDate);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(item.PosterPath), "item.PosterPath was not a valid image path, was: " + item.PosterPath);
|
||||
Assert.AreEqual(1, item.SeasonNumber);
|
||||
Assert.Equal(new DateTime(2004, 11, 16), item.AirDate);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.PosterPath), "item.PosterPath was not a valid image path, was: " + item.PosterPath);
|
||||
Assert.Equal(1, item.SeasonNumber);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Discover;
|
||||
using TMDbLib.Objects.General;
|
||||
using System.Linq;
|
||||
@ -8,36 +8,29 @@ using TMDbLibTests.JsonHelpers;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientDiscoverTests : TestBase
|
||||
{
|
||||
private TestConfig _config;
|
||||
private readonly TestConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public override void Initiator()
|
||||
public ClientDiscoverTests()
|
||||
{
|
||||
base.Initiator();
|
||||
|
||||
_config = new TestConfig();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestDiscoverTvShowsNoParams()
|
||||
{
|
||||
TestHelpers.SearchPages(i => _config.Client.DiscoverTvShowsAsync().Query(i).Result);
|
||||
|
||||
SearchContainer<SearchTv> result = _config.Client.DiscoverTvShowsAsync().Query().Result;
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.AreEqual(1, result.Page);
|
||||
Assert.IsNotNull(result.Results);
|
||||
Assert.IsTrue(result.Results.Any());
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(1, result.Page);
|
||||
Assert.NotNull(result.Results);
|
||||
Assert.True(result.Results.Any());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestDiscoverTvShows()
|
||||
{
|
||||
DiscoverTv query = _config.Client.DiscoverTvShowsAsync()
|
||||
@ -47,20 +40,20 @@ namespace TMDbLibTests
|
||||
TestHelpers.SearchPages(i => query.Query(i).Result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestDiscoverMoviesNoParams()
|
||||
{
|
||||
TestHelpers.SearchPages(i => _config.Client.DiscoverMoviesAsync().Query(i).Result);
|
||||
|
||||
SearchContainer<SearchMovie> result = _config.Client.DiscoverMoviesAsync().Query().Result;
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.AreEqual(1, result.Page);
|
||||
Assert.IsNotNull(result.Results);
|
||||
Assert.IsTrue(result.Results.Any());
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(1, result.Page);
|
||||
Assert.NotNull(result.Results);
|
||||
Assert.True(result.Results.Any());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestDiscoverMovies()
|
||||
{
|
||||
DiscoverMovie query = _config.Client.DiscoverMoviesAsync()
|
||||
|
@ -1,99 +1,92 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Find;
|
||||
using TMDbLibTests.Helpers;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientFindTests : TestBase
|
||||
{
|
||||
private TestConfig _config;
|
||||
private readonly TestConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public override void Initiator()
|
||||
public ClientFindTests()
|
||||
{
|
||||
base.Initiator();
|
||||
|
||||
_config = new TestConfig();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestFindImdbMovie()
|
||||
{
|
||||
Task<FindContainer> result = _config.Client.FindAsync(FindExternalSource.Imdb, IdHelper.ImdbTerminatorId);
|
||||
Assert.AreEqual(1, result.Result.MovieResults.Count);
|
||||
Assert.AreEqual(IdHelper.TmdbTerminatorId, result.Result.MovieResults[0].Id);
|
||||
Assert.Equal(1, result.Result.MovieResults.Count);
|
||||
Assert.Equal(IdHelper.TmdbTerminatorId, result.Result.MovieResults[0].Id);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestFindImdbPerson()
|
||||
{
|
||||
Task<FindContainer> result = _config.Client.FindAsync(FindExternalSource.Imdb, IdHelper.ImdbBruceWillis);
|
||||
Assert.AreEqual(1, result.Result.PersonResults.Count);
|
||||
Assert.AreEqual(IdHelper.BruceWillis, result.Result.PersonResults[0].Id);
|
||||
Assert.Equal(1, result.Result.PersonResults.Count);
|
||||
Assert.Equal(IdHelper.BruceWillis, result.Result.PersonResults[0].Id);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestFindImdbTvShowEpisode()
|
||||
{
|
||||
Task<FindContainer> result = _config.Client.FindAsync(FindExternalSource.Imdb, IdHelper.ImdbBreakingBadSeason1Episode1Id);
|
||||
Assert.AreEqual(1, result.Result.TvEpisode.Count);
|
||||
Assert.AreEqual(IdHelper.BreakingBadSeason1Episode1Id, result.Result.TvEpisode[0].Id);
|
||||
Assert.Equal(1, result.Result.TvEpisode.Count);
|
||||
Assert.Equal(IdHelper.BreakingBadSeason1Episode1Id, result.Result.TvEpisode[0].Id);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestFindImdbTvShowSeason()
|
||||
{
|
||||
Task<FindContainer> result = _config.Client.FindAsync(FindExternalSource.TvDb, IdHelper.TvdbBreakingBadSeason1Id);
|
||||
Assert.AreEqual(1, result.Result.TvEpisode.Count);
|
||||
Assert.Equal(1, result.Result.TvEpisode.Count);
|
||||
|
||||
Assert.AreEqual(1, result.Result.TvSeason.Count);
|
||||
Assert.AreEqual(IdHelper.BreakingBadSeason1Id, result.Result.TvSeason[0].Id);
|
||||
Assert.Equal(1, result.Result.TvSeason.Count);
|
||||
Assert.Equal(IdHelper.BreakingBadSeason1Id, result.Result.TvSeason[0].Id);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestFindTvdbTvShow()
|
||||
{
|
||||
Task<FindContainer> result = _config.Client.FindAsync(FindExternalSource.TvDb, IdHelper.TvdbBreakingBadId);
|
||||
Assert.AreEqual(1, result.Result.TvResults.Count);
|
||||
Assert.AreEqual(IdHelper.TmdbBreakingBadId, result.Result.TvResults[0].Id);
|
||||
Assert.Equal(1, result.Result.TvResults.Count);
|
||||
Assert.Equal(IdHelper.TmdbBreakingBadId, result.Result.TvResults[0].Id);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestFindImdbTvShow()
|
||||
{
|
||||
Task<FindContainer> result = _config.Client.FindAsync(FindExternalSource.Imdb, IdHelper.ImdbBreakingBadId);
|
||||
Assert.AreEqual(1, result.Result.TvResults.Count);
|
||||
Assert.AreEqual(IdHelper.TmdbBreakingBadId, result.Result.TvResults[0].Id);
|
||||
Assert.Equal(1, result.Result.TvResults.Count);
|
||||
Assert.Equal(IdHelper.TmdbBreakingBadId, result.Result.TvResults[0].Id);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestFindTvRageTvShow()
|
||||
{
|
||||
Task<FindContainer> result = _config.Client.FindAsync(FindExternalSource.TvRage, IdHelper.TvRageBreakingBadId);
|
||||
Assert.AreEqual(1, result.Result.TvResults.Count);
|
||||
Assert.AreEqual(IdHelper.TmdbBreakingBadId, result.Result.TvResults[0].Id);
|
||||
Assert.Equal(1, result.Result.TvResults.Count);
|
||||
Assert.Equal(IdHelper.TmdbBreakingBadId, result.Result.TvResults[0].Id);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestFindFreebaseTvShow()
|
||||
{
|
||||
Task<FindContainer> result = _config.Client.FindAsync(FindExternalSource.FreeBaseId, IdHelper.FreebaseBreakingBadId);
|
||||
Assert.AreEqual(1, result.Result.TvResults.Count);
|
||||
Assert.AreEqual(IdHelper.TmdbBreakingBadId, result.Result.TvResults[0].Id);
|
||||
Assert.Equal(1, result.Result.TvResults.Count);
|
||||
Assert.Equal(IdHelper.TmdbBreakingBadId, result.Result.TvResults[0].Id);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestFindFreebaseMidTvShow()
|
||||
{
|
||||
Task<FindContainer> result = _config.Client.FindAsync(FindExternalSource.FreeBaseMid, IdHelper.FreebaseMidBreakingBadId);
|
||||
Assert.AreEqual(1, result.Result.TvResults.Count);
|
||||
Assert.AreEqual(IdHelper.TmdbBreakingBadId, result.Result.TvResults[0].Id);
|
||||
Assert.Equal(1, result.Result.TvResults.Count);
|
||||
Assert.Equal(IdHelper.TmdbBreakingBadId, result.Result.TvResults[0].Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,94 +1,88 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLibTests.Helpers;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientGenreTests : TestBase
|
||||
{
|
||||
private TestConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public override void Initiator()
|
||||
public ClientGenreTests()
|
||||
{
|
||||
base.Initiator();
|
||||
|
||||
_config = new TestConfig();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestGenreTvList()
|
||||
{
|
||||
// Default language
|
||||
List<Genre> genres = _config.Client.GetTvGenresAsync().Result;
|
||||
List<Genre> genres = _config.Client.GetTvGenresAsync().Sync();
|
||||
|
||||
Assert.IsNotNull(genres);
|
||||
Assert.IsTrue(genres.Count > 0);
|
||||
Assert.NotNull(genres);
|
||||
Assert.True(genres.Count > 0);
|
||||
|
||||
// Another language
|
||||
List<Genre> genresDanish = _config.Client.GetTvGenresAsync("da").Result;
|
||||
|
||||
Assert.IsNotNull(genresDanish);
|
||||
Assert.IsTrue(genresDanish.Count > 0);
|
||||
Assert.NotNull(genresDanish);
|
||||
Assert.True(genresDanish.Count > 0);
|
||||
|
||||
Assert.AreEqual(genres.Count, genresDanish.Count);
|
||||
Assert.Equal(genres.Count, genresDanish.Count);
|
||||
|
||||
// At least one should be different
|
||||
Assert.IsTrue(genres.Any(genre => genresDanish.First(danishGenre => danishGenre.Id == genre.Id).Name != genre.Name));
|
||||
Assert.True(genres.Any(genre => genresDanish.First(danishGenre => danishGenre.Id == genre.Id).Name != genre.Name));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestGenreMovieList()
|
||||
{
|
||||
// Default language
|
||||
List<Genre> genres = _config.Client.GetMovieGenresAsync().Result;
|
||||
List<Genre> genres = _config.Client.GetMovieGenresAsync().Sync();
|
||||
|
||||
Assert.IsNotNull(genres);
|
||||
Assert.IsTrue(genres.Count > 0);
|
||||
Assert.NotNull(genres);
|
||||
Assert.True(genres.Count > 0);
|
||||
|
||||
// Another language
|
||||
List<Genre> genresDanish = _config.Client.GetMovieGenresAsync("da").Result;
|
||||
|
||||
Assert.IsNotNull(genresDanish);
|
||||
Assert.IsTrue(genresDanish.Count > 0);
|
||||
Assert.NotNull(genresDanish);
|
||||
Assert.True(genresDanish.Count > 0);
|
||||
|
||||
Assert.AreEqual(genres.Count, genresDanish.Count);
|
||||
Assert.Equal(genres.Count, genresDanish.Count);
|
||||
|
||||
// At least one should be different
|
||||
Assert.IsTrue(genres.Any(genre => genresDanish.First(danishGenre => danishGenre.Id == genre.Id).Name != genre.Name));
|
||||
Assert.True(genres.Any(genre => genresDanish.First(danishGenre => danishGenre.Id == genre.Id).Name != genre.Name));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestGenreMovies()
|
||||
{
|
||||
// Get first genre
|
||||
Genre genre = _config.Client.GetMovieGenresAsync().Result.First();
|
||||
Genre genre = _config.Client.GetMovieGenresAsync().Sync().First();
|
||||
|
||||
// Get movies
|
||||
SearchContainerWithId<MovieResult> movies = _config.Client.GetGenreMoviesAsync(genre.Id).Result;
|
||||
SearchContainerWithId<MovieResult> moviesPage2 = _config.Client.GetGenreMoviesAsync(genre.Id, "it", 2, includeAllMovies: false).Result;
|
||||
SearchContainerWithId<MovieResult> moviesAll = _config.Client.GetGenreMoviesAsync(genre.Id, includeAllMovies: true).Result;
|
||||
|
||||
Assert.AreEqual(1, movies.Page);
|
||||
Assert.AreEqual(2, moviesPage2.Page);
|
||||
Assert.AreEqual(1, moviesAll.Page);
|
||||
Assert.Equal(1, movies.Page);
|
||||
Assert.Equal(2, moviesPage2.Page);
|
||||
Assert.Equal(1, moviesAll.Page);
|
||||
|
||||
Assert.IsTrue(movies.Results.Count > 0);
|
||||
Assert.IsTrue(moviesPage2.Results.Count > 0);
|
||||
Assert.IsTrue(moviesAll.Results.Count > 0);
|
||||
Assert.True(movies.Results.Count > 0);
|
||||
Assert.True(moviesPage2.Results.Count > 0);
|
||||
Assert.True(moviesAll.Results.Count > 0);
|
||||
|
||||
Assert.IsTrue(movies.Results.All(s => s != null));
|
||||
Assert.IsTrue(moviesPage2.Results.All(s => s != null));
|
||||
Assert.IsTrue(moviesAll.Results.All(s => s != null));
|
||||
Assert.True(movies.Results.All(s => s != null));
|
||||
Assert.True(moviesPage2.Results.All(s => s != null));
|
||||
Assert.True(moviesAll.Results.All(s => s != null));
|
||||
|
||||
Assert.AreEqual(movies.TotalResults, moviesPage2.TotalResults); // Should be the same, despite the use of 'includeAllMovies' and Italian
|
||||
Assert.IsTrue(moviesAll.TotalResults >= movies.TotalResults);
|
||||
Assert.Equal(movies.TotalResults, moviesPage2.TotalResults); // Should be the same, despite the use of 'includeAllMovies' and Italian
|
||||
Assert.True(moviesAll.TotalResults >= movies.TotalResults);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.Movies;
|
||||
@ -10,188 +11,187 @@ using TMDbLibTests.JsonHelpers;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientGuestSessionTests : TestBase
|
||||
{
|
||||
private TestConfig _config;
|
||||
private readonly TestConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public override void Initiator()
|
||||
public ClientGuestSessionTests()
|
||||
{
|
||||
base.Initiator();
|
||||
|
||||
_config = new TestConfig();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvEpisodeSetRatingGuestSession()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.GuestTestSessionId, SessionType.GuestSession);
|
||||
|
||||
// Try changing the rating
|
||||
Assert.IsTrue(_config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 7.5).Result);
|
||||
Assert.True(_config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 7.5).Result);
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
SearchContainer<TvEpisodeWithRating> ratings = _config.Client.GetGuestSessionRatedTvEpisodesAsync().Result;
|
||||
SearchContainer<TvEpisodeWithRating> ratings = _config.Client.GetGuestSessionRatedTvEpisodesAsync().Sync();
|
||||
|
||||
Assert.IsTrue(ratings.Results.Any(s => s.ShowId == IdHelper.BreakingBad && s.SeasonNumber == 1 && s.EpisodeNumber == 1));
|
||||
Assert.AreEqual(7.5, ratings.Results.Single(s => s.ShowId == IdHelper.BreakingBad && s.SeasonNumber == 1 && s.EpisodeNumber == 1).Rating, float.Epsilon);
|
||||
double tmpRating = ratings.Results.Single(s => s.ShowId == IdHelper.BreakingBad && s.SeasonNumber == 1 && s.EpisodeNumber == 1).Rating;
|
||||
Assert.True(ratings.Results.Any(s => s.ShowId == IdHelper.BreakingBad && s.SeasonNumber == 1 && s.EpisodeNumber == 1));
|
||||
Assert.True(Math.Abs(7.5 - tmpRating) < float.Epsilon);
|
||||
|
||||
// Try changing it back to the previous rating
|
||||
Assert.IsTrue(_config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 8).Result);
|
||||
Assert.True(_config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 8).Result);
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
ratings = _config.Client.GetGuestSessionRatedTvEpisodesAsync().Result;
|
||||
ratings = _config.Client.GetGuestSessionRatedTvEpisodesAsync().Sync();
|
||||
|
||||
Assert.IsTrue(ratings.Results.Any(s => s.ShowId == IdHelper.BreakingBad && s.SeasonNumber == 1 && s.EpisodeNumber == 1));
|
||||
Assert.AreEqual(8, ratings.Results.Single(s => s.ShowId == IdHelper.BreakingBad && s.SeasonNumber == 1 && s.EpisodeNumber == 1).Rating, float.Epsilon);
|
||||
tmpRating = ratings.Results.Single(s => s.ShowId == IdHelper.BreakingBad && s.SeasonNumber == 1 && s.EpisodeNumber == 1).Rating;
|
||||
Assert.True(ratings.Results.Any(s => s.ShowId == IdHelper.BreakingBad && s.SeasonNumber == 1 && s.EpisodeNumber == 1));
|
||||
Assert.True(Math.Abs(8 - tmpRating) < float.Epsilon);
|
||||
|
||||
// Try removing the rating
|
||||
Assert.IsTrue(_config.Client.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 1).Result);
|
||||
Assert.True(_config.Client.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 1).Result);
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
ratings = _config.Client.GetGuestSessionRatedTvEpisodesAsync().Result;
|
||||
ratings = _config.Client.GetGuestSessionRatedTvEpisodesAsync().Sync();
|
||||
|
||||
Assert.IsFalse(ratings.Results.Any(s => s.ShowId == IdHelper.BreakingBad && s.SeasonNumber == 1 && s.EpisodeNumber == 1));
|
||||
Assert.False(ratings.Results.Any(s => s.ShowId == IdHelper.BreakingBad && s.SeasonNumber == 1 && s.EpisodeNumber == 1));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvSetRatingGuestSession()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.GuestTestSessionId, SessionType.GuestSession);
|
||||
|
||||
// Try changing the rating
|
||||
Assert.IsTrue(_config.Client.TvShowSetRatingAsync(IdHelper.House, 7.5).Result);
|
||||
Assert.True(_config.Client.TvShowSetRatingAsync(IdHelper.House, 7.5).Result);
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
SearchContainer<TvShowWithRating> ratings = _config.Client.GetGuestSessionRatedTvAsync().Result;
|
||||
SearchContainer<TvShowWithRating> ratings = _config.Client.GetGuestSessionRatedTvAsync().Sync();
|
||||
|
||||
Assert.IsTrue(ratings.Results.Any(s => s.Id == IdHelper.House));
|
||||
Assert.AreEqual(7.5, ratings.Results.Single(s => s.Id == IdHelper.House).Rating, float.Epsilon);
|
||||
double tmpRating = ratings.Results.Single(s => s.Id == IdHelper.House).Rating;
|
||||
Assert.True(ratings.Results.Any(s => s.Id == IdHelper.House));
|
||||
Assert.True(Math.Abs(7.5 - tmpRating) < float.Epsilon);
|
||||
|
||||
// Try changing it back to the previous rating
|
||||
Assert.IsTrue(_config.Client.TvShowSetRatingAsync(IdHelper.House, 8).Result);
|
||||
Assert.True(_config.Client.TvShowSetRatingAsync(IdHelper.House, 8).Result);
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
ratings = _config.Client.GetGuestSessionRatedTvAsync().Result;
|
||||
ratings = _config.Client.GetGuestSessionRatedTvAsync().Sync();
|
||||
|
||||
Assert.IsTrue(ratings.Results.Any(s => s.Id == IdHelper.House));
|
||||
Assert.AreEqual(8, ratings.Results.Single(s => s.Id == IdHelper.House).Rating, float.Epsilon);
|
||||
tmpRating = ratings.Results.Single(s => s.Id == IdHelper.House).Rating;
|
||||
Assert.True(ratings.Results.Any(s => s.Id == IdHelper.House));
|
||||
Assert.True(Math.Abs(8 - tmpRating) < float.Epsilon);
|
||||
|
||||
// Try removing the rating
|
||||
Assert.IsTrue(_config.Client.TvShowRemoveRatingAsync(IdHelper.House).Result);
|
||||
Assert.True(_config.Client.TvShowRemoveRatingAsync(IdHelper.House).Result);
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
ratings = _config.Client.GetGuestSessionRatedTvAsync().Result;
|
||||
ratings = _config.Client.GetGuestSessionRatedTvAsync().Sync();
|
||||
|
||||
Assert.IsFalse(ratings.Results.Any(s => s.Id == IdHelper.House));
|
||||
Assert.False(ratings.Results.Any(s => s.Id == IdHelper.House));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesSetRatingGuestSession()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.GuestTestSessionId, SessionType.GuestSession);
|
||||
|
||||
// Try changing the rating
|
||||
Assert.IsTrue(_config.Client.MovieSetRatingAsync(IdHelper.Avatar, 7.5).Result);
|
||||
Assert.True(_config.Client.MovieSetRatingAsync(IdHelper.Avatar, 7.5).Result);
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
SearchContainer<MovieWithRating> ratings = _config.Client.GetGuestSessionRatedMoviesAsync().Result;
|
||||
SearchContainer<MovieWithRating> ratings = _config.Client.GetGuestSessionRatedMoviesAsync().Sync();
|
||||
|
||||
Assert.IsTrue(ratings.Results.Any(s => s.Id == IdHelper.Avatar));
|
||||
Assert.AreEqual(7.5, ratings.Results.Single(s => s.Id == IdHelper.Avatar).Rating, float.Epsilon);
|
||||
double tmpRating = ratings.Results.Single(s => s.Id == IdHelper.Avatar).Rating;
|
||||
Assert.True(ratings.Results.Any(s => s.Id == IdHelper.Avatar));
|
||||
Assert.True(Math.Abs(7.5 - tmpRating) < float.Epsilon);
|
||||
|
||||
// Try changing it back to the previous rating
|
||||
Assert.IsTrue(_config.Client.MovieSetRatingAsync(IdHelper.Avatar, 8).Result);
|
||||
Assert.True(_config.Client.MovieSetRatingAsync(IdHelper.Avatar, 8).Result);
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
ratings = _config.Client.GetGuestSessionRatedMoviesAsync().Result;
|
||||
ratings = _config.Client.GetGuestSessionRatedMoviesAsync().Sync();
|
||||
|
||||
Assert.IsTrue(ratings.Results.Any(s => s.Id == IdHelper.Avatar));
|
||||
Assert.AreEqual(8, ratings.Results.Single(s => s.Id == IdHelper.Avatar).Rating, float.Epsilon);
|
||||
tmpRating = ratings.Results.Single(s => s.Id == IdHelper.Avatar).Rating;
|
||||
Assert.True(ratings.Results.Any(s => s.Id == IdHelper.Avatar));
|
||||
Assert.True(Math.Abs(8 - tmpRating) < float.Epsilon);
|
||||
|
||||
// Try removing the rating
|
||||
Assert.IsTrue(_config.Client.MovieRemoveRatingAsync(IdHelper.Avatar).Result);
|
||||
Assert.True(_config.Client.MovieRemoveRatingAsync(IdHelper.Avatar).Result);
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
ratings = _config.Client.GetGuestSessionRatedMoviesAsync().Result;
|
||||
ratings = _config.Client.GetGuestSessionRatedMoviesAsync().Sync();
|
||||
|
||||
Assert.IsFalse(ratings.Results.Any(s => s.Id == IdHelper.Avatar));
|
||||
Assert.False(ratings.Results.Any(s => s.Id == IdHelper.Avatar));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestGuestSessionGetRatedTvEpisodes()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.GuestTestSessionId, SessionType.GuestSession);
|
||||
|
||||
// Ensure we have a rating
|
||||
Assert.IsTrue(_config.Client.TvEpisodeSetRatingAsync(IdHelper.BigBangTheory, 1, 1, 7.5).Result);
|
||||
|
||||
Assert.True(_config.Client.TvEpisodeSetRatingAsync(IdHelper.BigBangTheory, 1, 1, 7.5).Result);
|
||||
|
||||
// Test paging
|
||||
TestHelpers.SearchPages(i => _config.Client.GetGuestSessionRatedTvEpisodesAsync(i).Result);
|
||||
|
||||
// Fetch ratings
|
||||
SearchContainer<TvEpisodeWithRating> result = _config.Client.GetGuestSessionRatedTvEpisodesAsync().Result;
|
||||
SearchContainer<TvEpisodeWithRating> result = _config.Client.GetGuestSessionRatedTvEpisodesAsync().Sync();
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsNotNull(result.Results);
|
||||
Assert.NotNull(result);
|
||||
Assert.NotNull(result.Results);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestGuestSessionGetRatedTv()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.GuestTestSessionId, SessionType.GuestSession);
|
||||
|
||||
// Ensure we have a rating
|
||||
Assert.IsTrue(_config.Client.TvShowSetRatingAsync(IdHelper.BigBangTheory, 7.5).Result);
|
||||
|
||||
Assert.True(_config.Client.TvShowSetRatingAsync(IdHelper.BigBangTheory, 7.5).Result);
|
||||
|
||||
// Test paging
|
||||
TestHelpers.SearchPages(i => _config.Client.GetGuestSessionRatedTvAsync(i).Result);
|
||||
|
||||
// Fetch ratings
|
||||
SearchContainer<TvShowWithRating> result = _config.Client.GetGuestSessionRatedTvAsync().Result;
|
||||
SearchContainer<TvShowWithRating> result = _config.Client.GetGuestSessionRatedTvAsync().Sync();
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsNotNull(result.Results);
|
||||
Assert.NotNull(result);
|
||||
Assert.NotNull(result.Results);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestGuestSessionGetRatedMovies()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.GuestTestSessionId, SessionType.GuestSession);
|
||||
|
||||
// Ensure we have a rating
|
||||
Assert.IsTrue(_config.Client.MovieSetRatingAsync(IdHelper.Terminator, 7.5).Result);
|
||||
|
||||
Assert.True(_config.Client.MovieSetRatingAsync(IdHelper.Terminator, 7.5).Result);
|
||||
|
||||
// Test paging
|
||||
TestHelpers.SearchPages(i => _config.Client.GetGuestSessionRatedMoviesAsync(i).Result);
|
||||
|
||||
// Fetch ratings
|
||||
SearchContainer<MovieWithRating> result = _config.Client.GetGuestSessionRatedMoviesAsync().Result;
|
||||
SearchContainer<MovieWithRating> result = _config.Client.GetGuestSessionRatedMoviesAsync().Sync();
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsNotNull(result.Results);
|
||||
Assert.NotNull(result);
|
||||
Assert.NotNull(result.Results);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,38 +1,32 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLibTests.Helpers;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientJobTests : TestBase
|
||||
{
|
||||
private TestConfig _config;
|
||||
private readonly TestConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public override void Initiator()
|
||||
public ClientJobTests()
|
||||
{
|
||||
base.Initiator();
|
||||
|
||||
_config = new TestConfig();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestJobList()
|
||||
{
|
||||
List<Job> jobs = _config.Client.GetJobsAsync().Result;
|
||||
List<Job> jobs = _config.Client.GetJobsAsync().Sync();
|
||||
|
||||
Assert.IsNotNull(jobs);
|
||||
Assert.IsTrue(jobs.Count > 0);
|
||||
Assert.NotNull(jobs);
|
||||
Assert.True(jobs.Count > 0);
|
||||
|
||||
Assert.IsTrue(jobs.All(job => !string.IsNullOrEmpty(job.Department)));
|
||||
Assert.IsTrue(jobs.All(job => job.JobList != null));
|
||||
Assert.IsTrue(jobs.All(job => job.JobList.Count > 0));
|
||||
Assert.True(jobs.All(job => !string.IsNullOrEmpty(job.Department)));
|
||||
Assert.True(jobs.All(job => job.JobList != null));
|
||||
Assert.True(jobs.All(job => job.JobList.Count > 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.Movies;
|
||||
using TMDbLibTests.Helpers;
|
||||
@ -7,51 +7,44 @@ using TMDbLibTests.JsonHelpers;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientKeywordTests : TestBase
|
||||
{
|
||||
private TestConfig _config;
|
||||
private readonly TestConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public override void Initiator()
|
||||
public ClientKeywordTests()
|
||||
{
|
||||
base.Initiator();
|
||||
|
||||
_config = new TestConfig();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestKeywordGet()
|
||||
{
|
||||
KeywordsContainer keywords = _config.Client.GetMovieKeywordsAsync(IdHelper.AGoodDayToDieHard).Result;
|
||||
|
||||
Assert.IsNotNull(keywords);
|
||||
Assert.IsNotNull(keywords.Keywords);
|
||||
Assert.IsTrue(keywords.Keywords.Count > 0);
|
||||
Assert.NotNull(keywords);
|
||||
Assert.NotNull(keywords.Keywords);
|
||||
Assert.True(keywords.Keywords.Count > 0);
|
||||
|
||||
// Try to get all keywords
|
||||
foreach (Keyword testKeyword in keywords.Keywords)
|
||||
{
|
||||
Keyword getKeyword = _config.Client.GetKeywordAsync(testKeyword.Id).Result;
|
||||
|
||||
Assert.IsNotNull(getKeyword);
|
||||
Assert.NotNull(getKeyword);
|
||||
|
||||
Assert.AreEqual(testKeyword.Id, getKeyword.Id);
|
||||
Assert.AreEqual(testKeyword.Name, getKeyword.Name);
|
||||
Assert.Equal(testKeyword.Id, getKeyword.Id);
|
||||
Assert.Equal(testKeyword.Name, getKeyword.Name);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestKeywordMovies()
|
||||
{
|
||||
KeywordsContainer keywords = _config.Client.GetMovieKeywordsAsync(IdHelper.AGoodDayToDieHard).Result;
|
||||
|
||||
Assert.IsNotNull(keywords);
|
||||
Assert.IsNotNull(keywords.Keywords);
|
||||
Assert.IsTrue(keywords.Keywords.Count > 0);
|
||||
Assert.NotNull(keywords);
|
||||
Assert.NotNull(keywords.Keywords);
|
||||
Assert.True(keywords.Keywords.Count > 0);
|
||||
|
||||
// Get first keyword
|
||||
Keyword testKeyword = keywords.Keywords.First();
|
||||
@ -61,34 +54,34 @@ namespace TMDbLibTests
|
||||
SearchContainer<MovieResult> moviesItalian = _config.Client.GetKeywordMoviesAsync(testKeyword.Id, "it").Result;
|
||||
SearchContainer<MovieResult> moviesPage2 = _config.Client.GetKeywordMoviesAsync(testKeyword.Id, 2).Result;
|
||||
|
||||
Assert.IsNotNull(movies);
|
||||
Assert.IsNotNull(moviesItalian);
|
||||
Assert.IsNotNull(moviesPage2);
|
||||
Assert.NotNull(movies);
|
||||
Assert.NotNull(moviesItalian);
|
||||
Assert.NotNull(moviesPage2);
|
||||
|
||||
Assert.IsTrue(movies.Results.Count > 0);
|
||||
Assert.IsTrue(moviesItalian.Results.Count > 0);
|
||||
Assert.True(movies.Results.Count > 0);
|
||||
Assert.True(moviesItalian.Results.Count > 0);
|
||||
|
||||
if (movies.TotalResults > movies.Results.Count)
|
||||
Assert.IsTrue(moviesPage2.Results.Count > 0);
|
||||
Assert.True(moviesPage2.Results.Count > 0);
|
||||
else
|
||||
Assert.AreEqual(0, moviesPage2.Results.Count);
|
||||
Assert.Equal(0, moviesPage2.Results.Count);
|
||||
|
||||
Assert.AreEqual(1, movies.Page);
|
||||
Assert.AreEqual(1, moviesItalian.Page);
|
||||
Assert.AreEqual(2, moviesPage2.Page);
|
||||
Assert.Equal(1, movies.Page);
|
||||
Assert.Equal(1, moviesItalian.Page);
|
||||
Assert.Equal(2, moviesPage2.Page);
|
||||
|
||||
// All titles on page 1 must be the same
|
||||
bool allTitlesIdentical = true;
|
||||
for (int index = 0; index < movies.Results.Count; index++)
|
||||
{
|
||||
Assert.AreEqual(movies.Results[index].Id, moviesItalian.Results[index].Id);
|
||||
Assert.Equal(movies.Results[index].Id, moviesItalian.Results[index].Id);
|
||||
|
||||
// At least one title must differ in title
|
||||
if (movies.Results[index].Title != moviesItalian.Results[index].Title)
|
||||
allTitlesIdentical = false;
|
||||
}
|
||||
|
||||
Assert.IsFalse(allTitlesIdentical);
|
||||
Assert.False(allTitlesIdentical);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.Lists;
|
||||
@ -9,36 +10,29 @@ using TMDbLibTests.JsonHelpers;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientListsTests : TestBase
|
||||
{
|
||||
private TestConfig _config;
|
||||
private readonly TestConfig _config;
|
||||
private const string TestListId = "528349d419c2954bd21ca0a8";
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public override void Initiator()
|
||||
public ClientListsTests()
|
||||
{
|
||||
base.Initiator();
|
||||
|
||||
_config = new TestConfig();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestList()
|
||||
{
|
||||
// Get list
|
||||
List list = _config.Client.GetListAsync(TestListId).Result;
|
||||
|
||||
Assert.IsNotNull(list);
|
||||
Assert.AreEqual(TestListId, list.Id);
|
||||
Assert.AreEqual(list.ItemCount, list.Items.Count);
|
||||
Assert.NotNull(list);
|
||||
Assert.Equal(TestListId, list.Id);
|
||||
Assert.Equal(list.ItemCount, list.Items.Count);
|
||||
|
||||
foreach (MovieResult movieResult in list.Items)
|
||||
{
|
||||
Assert.IsNotNull(movieResult);
|
||||
Assert.NotNull(movieResult);
|
||||
|
||||
// Ensure all movies point to this list
|
||||
int page = 1;
|
||||
@ -56,31 +50,31 @@ namespace TMDbLibTests
|
||||
if (movieLists.Page < movieLists.TotalPages)
|
||||
movieLists = _config.Client.GetMovieListsAsync(movieResult.Id, ++page).Result;
|
||||
else
|
||||
Assert.Fail("Movie '{0}' was not linked to the test list", movieResult.Title);
|
||||
throw new Exception($"Movie '{movieResult.Title}' was not linked to the test list");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestListIsMoviePresentFailure()
|
||||
{
|
||||
Assert.IsFalse(_config.Client.GetListIsMoviePresentAsync(TestListId, IdHelper.Terminator).Result);
|
||||
Assert.False(_config.Client.GetListIsMoviePresentAsync(TestListId, IdHelper.Terminator).Result);
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Clear list
|
||||
Assert.IsTrue(_config.Client.ListClearAsync(TestListId).Result);
|
||||
Assert.True(_config.Client.ListClearAsync(TestListId).Result);
|
||||
|
||||
// Verify Avatar is not present
|
||||
Assert.IsFalse(_config.Client.GetListIsMoviePresentAsync(TestListId, IdHelper.Avatar).Result);
|
||||
Assert.False(_config.Client.GetListIsMoviePresentAsync(TestListId, IdHelper.Avatar).Result);
|
||||
|
||||
// Add Avatar
|
||||
Assert.IsTrue(_config.Client.ListAddMovieAsync(TestListId, IdHelper.Avatar).Result);
|
||||
Assert.True(_config.Client.ListAddMovieAsync(TestListId, IdHelper.Avatar).Result);
|
||||
|
||||
// Verify Avatar is present
|
||||
Assert.IsTrue(_config.Client.GetListIsMoviePresentAsync(TestListId, IdHelper.Avatar).Result);
|
||||
Assert.True(_config.Client.GetListIsMoviePresentAsync(TestListId, IdHelper.Avatar).Result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestListCreateAndDelete()
|
||||
{
|
||||
const string listName = "Test List 123";
|
||||
@ -88,70 +82,70 @@ namespace TMDbLibTests
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
string newListId = _config.Client.ListCreateAsync(listName).Result;
|
||||
|
||||
Assert.IsFalse(string.IsNullOrWhiteSpace(newListId));
|
||||
Assert.False(string.IsNullOrWhiteSpace(newListId));
|
||||
|
||||
List newlyAddedList = _config.Client.GetListAsync(newListId).Result;
|
||||
Assert.IsNotNull(newlyAddedList);
|
||||
Assert.AreEqual(listName, newlyAddedList.Name);
|
||||
Assert.AreEqual("", newlyAddedList.Description); // "" is the default value
|
||||
Assert.AreEqual("en", newlyAddedList.Iso_639_1); // en is the default value
|
||||
Assert.AreEqual(0, newlyAddedList.ItemCount);
|
||||
Assert.AreEqual(0, newlyAddedList.Items.Count);
|
||||
Assert.IsFalse(string.IsNullOrWhiteSpace(newlyAddedList.CreatedBy));
|
||||
Assert.NotNull(newlyAddedList);
|
||||
Assert.Equal(listName, newlyAddedList.Name);
|
||||
Assert.Equal("", newlyAddedList.Description); // "" is the default value
|
||||
Assert.Equal("en", newlyAddedList.Iso_639_1); // en is the default value
|
||||
Assert.Equal(0, newlyAddedList.ItemCount);
|
||||
Assert.Equal(0, newlyAddedList.Items.Count);
|
||||
Assert.False(string.IsNullOrWhiteSpace(newlyAddedList.CreatedBy));
|
||||
|
||||
Assert.IsTrue(_config.Client.ListDeleteAsync(newListId).Result);
|
||||
Assert.True(_config.Client.ListDeleteAsync(newListId).Result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestListDeleteFailure()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Try removing a list with an incorrect id
|
||||
Assert.IsFalse(_config.Client.ListDeleteAsync("bla").Result);
|
||||
Assert.False(_config.Client.ListDeleteAsync("bla").Result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestListAddAndRemoveMovie()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Add a new movie to the list
|
||||
Assert.IsTrue(_config.Client.ListAddMovieAsync(TestListId, IdHelper.EvanAlmighty).Result);
|
||||
Assert.True(_config.Client.ListAddMovieAsync(TestListId, IdHelper.EvanAlmighty).Result);
|
||||
|
||||
// Try again, this time it should fail since the list already contains this movie
|
||||
Assert.IsFalse(_config.Client.ListAddMovieAsync(TestListId, IdHelper.EvanAlmighty).Result);
|
||||
Assert.False(_config.Client.ListAddMovieAsync(TestListId, IdHelper.EvanAlmighty).Result);
|
||||
|
||||
// Get list and check if the item was added
|
||||
List listAfterAdd = _config.Client.GetListAsync(TestListId).Result;
|
||||
Assert.IsTrue(listAfterAdd.Items.Any(m => m.Id == IdHelper.EvanAlmighty));
|
||||
Assert.True(listAfterAdd.Items.Any(m => m.Id == IdHelper.EvanAlmighty));
|
||||
|
||||
// Remove the previously added movie from the list
|
||||
Assert.IsTrue(_config.Client.ListRemoveMovieAsync(TestListId, IdHelper.EvanAlmighty).Result);
|
||||
Assert.True(_config.Client.ListRemoveMovieAsync(TestListId, IdHelper.EvanAlmighty).Result);
|
||||
|
||||
// Get list and check if the item was removed
|
||||
List listAfterRemove = _config.Client.GetListAsync(TestListId).Result;
|
||||
Assert.IsFalse(listAfterRemove.Items.Any(m => m.Id == IdHelper.EvanAlmighty));
|
||||
Assert.False(listAfterRemove.Items.Any(m => m.Id == IdHelper.EvanAlmighty));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestListClear()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Add a new movie to the list
|
||||
Assert.IsTrue(_config.Client.ListAddMovieAsync(TestListId, IdHelper.MadMaxFuryRoad).Result);
|
||||
Assert.True(_config.Client.ListAddMovieAsync(TestListId, IdHelper.MadMaxFuryRoad).Result);
|
||||
|
||||
// Get list and check if the item was added
|
||||
List listAfterAdd = _config.Client.GetListAsync(TestListId).Result;
|
||||
Assert.IsTrue(listAfterAdd.Items.Any(m => m.Id == IdHelper.MadMaxFuryRoad));
|
||||
Assert.True(listAfterAdd.Items.Any(m => m.Id == IdHelper.MadMaxFuryRoad));
|
||||
|
||||
// Clear the list
|
||||
Assert.IsTrue(_config.Client.ListClearAsync(TestListId).Result);
|
||||
Assert.True(_config.Client.ListClearAsync(TestListId).Result);
|
||||
|
||||
// Get list and check that all items were removed
|
||||
List listAfterRemove = _config.Client.GetListAsync(TestListId).Result;
|
||||
Assert.IsFalse(listAfterRemove.Items.Any());
|
||||
Assert.False(listAfterRemove.Items.Any());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
using TMDbLib.Objects.Changes;
|
||||
using TMDbLib.Objects.General;
|
||||
@ -15,46 +15,34 @@ using Credits = TMDbLib.Objects.Movies.Credits;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientMovieTests : TestBase
|
||||
{
|
||||
private static Dictionary<MovieMethods, Func<Movie, object>> _methods;
|
||||
private TestConfig _config;
|
||||
private readonly TestConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public override void Initiator()
|
||||
public ClientMovieTests()
|
||||
{
|
||||
base.Initiator();
|
||||
|
||||
_config = new TestConfig();
|
||||
|
||||
_methods = new Dictionary<MovieMethods, Func<Movie, object>>
|
||||
{
|
||||
[MovieMethods.AlternativeTitles] = movie => movie.AlternativeTitles,
|
||||
[MovieMethods.Credits] = movie => movie.Credits,
|
||||
[MovieMethods.Images] = movie => movie.Images,
|
||||
[MovieMethods.Keywords] = movie => movie.Keywords,
|
||||
[MovieMethods.Releases] = movie => movie.Releases,
|
||||
[MovieMethods.Videos] = movie => movie.Videos,
|
||||
[MovieMethods.Translations] = movie => movie.Translations,
|
||||
[MovieMethods.Similar] = movie => movie.Similar,
|
||||
[MovieMethods.Reviews] = movie => movie.Reviews,
|
||||
[MovieMethods.Lists] = movie => movie.Lists,
|
||||
[MovieMethods.Changes] = movie => movie.Changes,
|
||||
[MovieMethods.AccountStates] = movie => movie.AccountStates,
|
||||
[MovieMethods.ReleaseDates] = movie => movie.ReleaseDates
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on test class initialization
|
||||
/// </summary>
|
||||
[ClassInitialize]
|
||||
public static void InitialInitiator(TestContext context)
|
||||
{
|
||||
_methods = new Dictionary<MovieMethods, Func<Movie, object>>();
|
||||
_methods[MovieMethods.AlternativeTitles] = movie => movie.AlternativeTitles;
|
||||
_methods[MovieMethods.Credits] = movie => movie.Credits;
|
||||
_methods[MovieMethods.Images] = movie => movie.Images;
|
||||
_methods[MovieMethods.Keywords] = movie => movie.Keywords;
|
||||
_methods[MovieMethods.Releases] = movie => movie.Releases;
|
||||
_methods[MovieMethods.Videos] = movie => movie.Videos;
|
||||
_methods[MovieMethods.Translations] = movie => movie.Translations;
|
||||
_methods[MovieMethods.Similar] = movie => movie.Similar;
|
||||
_methods[MovieMethods.Reviews] = movie => movie.Reviews;
|
||||
_methods[MovieMethods.Lists] = movie => movie.Lists;
|
||||
_methods[MovieMethods.Changes] = movie => movie.Changes;
|
||||
_methods[MovieMethods.AccountStates] = movie => movie.AccountStates;
|
||||
_methods[MovieMethods.ReleaseDates] = movie => movie.ReleaseDates;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesExtrasNone()
|
||||
{
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
@ -62,19 +50,19 @@ namespace TMDbLibTests
|
||||
|
||||
Movie movie = _config.Client.GetMovieAsync(IdHelper.AGoodDayToDieHard).Result;
|
||||
|
||||
Assert.IsNotNull(movie);
|
||||
Assert.NotNull(movie);
|
||||
|
||||
// TODO: Test all properties
|
||||
Assert.AreEqual("A Good Day to Die Hard", movie.Title);
|
||||
Assert.Equal("A Good Day to Die Hard", movie.Title);
|
||||
|
||||
// Test all extras, ensure none of them exist
|
||||
foreach (Func<Movie, object> selector in _methods.Values)
|
||||
{
|
||||
Assert.IsNull(selector(movie));
|
||||
Assert.Null(selector(movie));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesExtrasExclusive()
|
||||
{
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
@ -84,7 +72,7 @@ namespace TMDbLibTests
|
||||
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetMovieAsync(id, extras).Result, IdHelper.AGoodDayToDieHard);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesImdbExtrasAll()
|
||||
{
|
||||
Dictionary<MovieMethods, Func<Movie, object>> tmpMethods = new Dictionary<MovieMethods, Func<Movie, object>>(_methods);
|
||||
@ -93,7 +81,7 @@ namespace TMDbLibTests
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Account states will only show up if we've done something
|
||||
_config.Client.MovieSetRatingAsync(IdHelper.TheDarkKnightRises, 5).Wait();
|
||||
_config.Client.MovieSetRatingAsync(IdHelper.TheDarkKnightRises, 5).Sync();
|
||||
|
||||
MovieMethods combinedEnum = tmpMethods.Keys.Aggregate((methods, movieMethods) => methods | movieMethods);
|
||||
Movie item = _config.Client.GetMovieAsync(IdHelper.TheDarkKnightRises, combinedEnum).Result;
|
||||
@ -101,7 +89,7 @@ namespace TMDbLibTests
|
||||
TestMethodsHelper.TestAllNotNull(tmpMethods, item);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesExtrasAll()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
@ -111,259 +99,259 @@ namespace TMDbLibTests
|
||||
TestMethodsHelper.TestAllNotNull(_methods, item);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesLanguage()
|
||||
{
|
||||
Movie movie = _config.Client.GetMovieAsync(IdHelper.AGoodDayToDieHard).Result;
|
||||
Movie movieItalian = _config.Client.GetMovieAsync(IdHelper.AGoodDayToDieHard, "it").Result;
|
||||
|
||||
Assert.IsNotNull(movie);
|
||||
Assert.IsNotNull(movieItalian);
|
||||
Assert.NotNull(movie);
|
||||
Assert.NotNull(movieItalian);
|
||||
|
||||
Assert.AreEqual("A Good Day to Die Hard", movie.Title);
|
||||
Assert.AreNotEqual(movie.Title, movieItalian.Title);
|
||||
Assert.Equal("A Good Day to Die Hard", movie.Title);
|
||||
Assert.NotEqual(movie.Title, movieItalian.Title);
|
||||
|
||||
// Test all extras, ensure none of them exist
|
||||
foreach (Func<Movie, object> selector in _methods.Values)
|
||||
{
|
||||
Assert.IsNull(selector(movie));
|
||||
Assert.IsNull(selector(movieItalian));
|
||||
Assert.Null(selector(movie));
|
||||
Assert.Null(selector(movieItalian));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesGetMovieAlternativeTitles()
|
||||
{
|
||||
//GetMovieAlternativeTitlesAsync(int id, string country)
|
||||
AlternativeTitles respUs = _config.Client.GetMovieAlternativeTitlesAsync(IdHelper.AGoodDayToDieHard, "US").Result;
|
||||
Assert.IsNotNull(respUs);
|
||||
Assert.NotNull(respUs);
|
||||
|
||||
AlternativeTitles respFrench = _config.Client.GetMovieAlternativeTitlesAsync(IdHelper.AGoodDayToDieHard, "FR").Result;
|
||||
Assert.IsNotNull(respFrench);
|
||||
Assert.NotNull(respFrench);
|
||||
|
||||
Assert.IsFalse(respUs.Titles.Any(s => s.Title == "Duro de matar 5"));
|
||||
Assert.IsTrue(respFrench.Titles.Any(s => s.Title == "Die Hard 5 - Belle Journée Pour mourir"));
|
||||
Assert.False(respUs.Titles.Any(s => s.Title == "Duro de matar 5"));
|
||||
Assert.True(respFrench.Titles.Any(s => s.Title == "Die Hard 5 - Belle Journée Pour mourir"));
|
||||
|
||||
Assert.IsTrue(respUs.Titles.All(s => s.Iso_3166_1 == "US"));
|
||||
Assert.IsTrue(respFrench.Titles.All(s => s.Iso_3166_1 == "FR"));
|
||||
Assert.True(respUs.Titles.All(s => s.Iso_3166_1 == "US"));
|
||||
Assert.True(respFrench.Titles.All(s => s.Iso_3166_1 == "FR"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesGetMovieReleaseDates()
|
||||
{
|
||||
ResultContainer<ReleaseDatesContainer> resp = _config.Client.GetMovieReleaseDatesAsync(IdHelper.AGoodDayToDieHard).Result;
|
||||
Assert.IsNotNull(resp);
|
||||
Assert.NotNull(resp);
|
||||
|
||||
ReleaseDatesContainer releasesUs = resp.Results.SingleOrDefault(s => s.Iso_3166_1 == "US");
|
||||
Assert.IsNotNull(releasesUs);
|
||||
Assert.AreEqual(1, releasesUs.ReleaseDates.Count);
|
||||
Assert.NotNull(releasesUs);
|
||||
Assert.Equal(1, releasesUs.ReleaseDates.Count);
|
||||
|
||||
ReleaseDateItem singleRelease = releasesUs.ReleaseDates.First();
|
||||
|
||||
Assert.AreEqual("R", singleRelease.Certification);
|
||||
Assert.AreEqual(string.Empty, singleRelease.Iso_639_1);
|
||||
Assert.AreEqual(string.Empty, singleRelease.Note);
|
||||
Assert.AreEqual(DateTime.Parse("2013-02-14T00:00:00.000Z").ToUniversalTime(), singleRelease.ReleaseDate);
|
||||
Assert.AreEqual(ReleaseDateType.Theatrical, singleRelease.Type);
|
||||
Assert.Equal("R", singleRelease.Certification);
|
||||
Assert.Equal(string.Empty, singleRelease.Iso_639_1);
|
||||
Assert.Equal(string.Empty, singleRelease.Note);
|
||||
Assert.Equal(DateTime.Parse("2013-02-14T00:00:00.000Z").ToUniversalTime(), singleRelease.ReleaseDate);
|
||||
Assert.Equal(ReleaseDateType.Theatrical, singleRelease.Type);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesGetMovieAlternativeTitlesCountry()
|
||||
{
|
||||
AlternativeTitles respUs = _config.Client.GetMovieAlternativeTitlesAsync(IdHelper.AGoodDayToDieHard, "US").Result;
|
||||
Assert.IsNotNull(respUs);
|
||||
Assert.NotNull(respUs);
|
||||
|
||||
_config.Client.DefaultCountry = "US";
|
||||
|
||||
AlternativeTitles respUs2 = _config.Client.GetMovieAlternativeTitlesAsync(IdHelper.AGoodDayToDieHard).Result;
|
||||
Assert.IsNotNull(respUs2);
|
||||
Assert.NotNull(respUs2);
|
||||
|
||||
Assert.AreEqual(respUs.Titles.Count, respUs2.Titles.Count);
|
||||
Assert.Equal(respUs.Titles.Count, respUs2.Titles.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesGetMovieCasts()
|
||||
{
|
||||
Credits resp = _config.Client.GetMovieCreditsAsync(IdHelper.AGoodDayToDieHard).Result;
|
||||
Assert.IsNotNull(resp);
|
||||
Assert.NotNull(resp);
|
||||
|
||||
Cast cast = resp.Cast.SingleOrDefault(s => s.Name == "Bruce Willis");
|
||||
Assert.IsNotNull(cast);
|
||||
Assert.NotNull(cast);
|
||||
|
||||
Assert.AreEqual(1, cast.CastId);
|
||||
Assert.AreEqual("John McClane", cast.Character);
|
||||
Assert.AreEqual("52fe4751c3a36847f812f049", cast.CreditId);
|
||||
Assert.AreEqual(62, cast.Id);
|
||||
Assert.AreEqual("Bruce Willis", cast.Name);
|
||||
Assert.AreEqual(0, cast.Order);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(cast.ProfilePath), "cast.ProfilePath was not a valid image path, was: " + cast.ProfilePath);
|
||||
Assert.Equal(1, cast.CastId);
|
||||
Assert.Equal("John McClane", cast.Character);
|
||||
Assert.Equal("52fe4751c3a36847f812f049", cast.CreditId);
|
||||
Assert.Equal(62, cast.Id);
|
||||
Assert.Equal("Bruce Willis", cast.Name);
|
||||
Assert.Equal(0, cast.Order);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(cast.ProfilePath), "cast.ProfilePath was not a valid image path, was: " + cast.ProfilePath);
|
||||
|
||||
Crew crew = resp.Crew.SingleOrDefault(s => s.Name == "Marco Beltrami");
|
||||
Assert.IsNotNull(crew);
|
||||
Assert.NotNull(crew);
|
||||
|
||||
Assert.AreEqual("5336b0e09251417d9b000cc7", crew.CreditId);
|
||||
Assert.AreEqual("Sound", crew.Department);
|
||||
Assert.AreEqual(7229, crew.Id);
|
||||
Assert.AreEqual("Music", crew.Job);
|
||||
Assert.AreEqual("Marco Beltrami", crew.Name);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(crew.ProfilePath), "crew.ProfilePath was not a valid image path, was: " + crew.ProfilePath);
|
||||
Assert.Equal("5336b0e09251417d9b000cc7", crew.CreditId);
|
||||
Assert.Equal("Sound", crew.Department);
|
||||
Assert.Equal(7229, crew.Id);
|
||||
Assert.Equal("Music", crew.Job);
|
||||
Assert.Equal("Marco Beltrami", crew.Name);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(crew.ProfilePath), "crew.ProfilePath was not a valid image path, was: " + crew.ProfilePath);
|
||||
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesGetMovieImages()
|
||||
{
|
||||
ImagesWithId resp = _config.Client.GetMovieImagesAsync(IdHelper.AGoodDayToDieHard).Result;
|
||||
Assert.IsNotNull(resp);
|
||||
Assert.NotNull(resp);
|
||||
|
||||
ImageData backdrop = resp.Backdrops.SingleOrDefault(s => s.FilePath == "/17zArExB7ztm6fjUXZwQWgGMC9f.jpg");
|
||||
Assert.IsNotNull(backdrop);
|
||||
Assert.NotNull(backdrop);
|
||||
|
||||
Assert.IsTrue(Math.Abs(1.77777777777778 - backdrop.AspectRatio) < double.Epsilon);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(backdrop.FilePath), "backdrop.FilePath was not a valid image path, was: " + backdrop.FilePath);
|
||||
Assert.AreEqual(1080, backdrop.Height);
|
||||
Assert.AreEqual("xx", backdrop.Iso_639_1);
|
||||
Assert.IsTrue(backdrop.VoteAverage > 0);
|
||||
Assert.IsTrue(backdrop.VoteCount > 0);
|
||||
Assert.AreEqual(1920, backdrop.Width);
|
||||
Assert.True(Math.Abs(1.77777777777778 - backdrop.AspectRatio) < double.Epsilon);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(backdrop.FilePath), "backdrop.FilePath was not a valid image path, was: " + backdrop.FilePath);
|
||||
Assert.Equal(1080, backdrop.Height);
|
||||
Assert.Equal("xx", backdrop.Iso_639_1);
|
||||
Assert.True(backdrop.VoteAverage > 0);
|
||||
Assert.True(backdrop.VoteCount > 0);
|
||||
Assert.Equal(1920, backdrop.Width);
|
||||
|
||||
ImageData poster = resp.Posters.SingleOrDefault(s => s.FilePath == "/c2SQMd00CCGTiDxGXVqA2J9lmzF.jpg");
|
||||
Assert.IsNotNull(poster);
|
||||
Assert.NotNull(poster);
|
||||
|
||||
Assert.IsTrue(Math.Abs(0.666666666666667 - poster.AspectRatio) < double.Epsilon);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(poster.FilePath), "poster.FilePath was not a valid image path, was: " + poster.FilePath);
|
||||
Assert.AreEqual(1500, poster.Height);
|
||||
Assert.AreEqual("en", poster.Iso_639_1);
|
||||
Assert.IsTrue(poster.VoteAverage > 0);
|
||||
Assert.IsTrue(poster.VoteCount > 0);
|
||||
Assert.AreEqual(1000, poster.Width);
|
||||
Assert.True(Math.Abs(0.666666666666667 - poster.AspectRatio) < double.Epsilon);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(poster.FilePath), "poster.FilePath was not a valid image path, was: " + poster.FilePath);
|
||||
Assert.Equal(1500, poster.Height);
|
||||
Assert.Equal("en", poster.Iso_639_1);
|
||||
Assert.True(poster.VoteAverage > 0);
|
||||
Assert.True(poster.VoteCount > 0);
|
||||
Assert.Equal(1000, poster.Width);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesGetMovieKeywords()
|
||||
{
|
||||
KeywordsContainer resp = _config.Client.GetMovieKeywordsAsync(IdHelper.AGoodDayToDieHard).Result;
|
||||
Assert.IsNotNull(resp);
|
||||
Assert.NotNull(resp);
|
||||
|
||||
Keyword keyword = resp.Keywords.SingleOrDefault(s => s.Id == 186447);
|
||||
Assert.IsNotNull(keyword);
|
||||
Assert.NotNull(keyword);
|
||||
|
||||
Assert.AreEqual(186447, keyword.Id);
|
||||
Assert.AreEqual("rogue", keyword.Name);
|
||||
Assert.Equal(186447, keyword.Id);
|
||||
Assert.Equal("rogue", keyword.Name);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesGetMovieReleases()
|
||||
{
|
||||
Releases resp = _config.Client.GetMovieReleasesAsync(IdHelper.AGoodDayToDieHard).Result;
|
||||
Assert.IsNotNull(resp);
|
||||
Assert.NotNull(resp);
|
||||
|
||||
Country country = resp.Countries.SingleOrDefault(s => s.Iso_3166_1 == "US");
|
||||
Assert.IsNotNull(country);
|
||||
Assert.NotNull(country);
|
||||
|
||||
Assert.AreEqual("R", country.Certification);
|
||||
Assert.AreEqual("US", country.Iso_3166_1);
|
||||
Assert.AreEqual(false, country.Primary);
|
||||
Assert.AreEqual(new DateTime(2013, 2, 14), country.ReleaseDate);
|
||||
Assert.Equal("R", country.Certification);
|
||||
Assert.Equal("US", country.Iso_3166_1);
|
||||
Assert.Equal(false, country.Primary);
|
||||
Assert.Equal(new DateTime(2013, 2, 14), country.ReleaseDate);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesGetMovieVideos()
|
||||
{
|
||||
ResultContainer<Video> resp = _config.Client.GetMovieVideosAsync(IdHelper.AGoodDayToDieHard).Result;
|
||||
Assert.IsNotNull(resp);
|
||||
Assert.NotNull(resp);
|
||||
|
||||
Assert.IsNotNull(resp);
|
||||
Assert.IsNotNull(resp.Results);
|
||||
Assert.NotNull(resp);
|
||||
Assert.NotNull(resp.Results);
|
||||
|
||||
Video video = resp.Results[0];
|
||||
Assert.IsNotNull(video);
|
||||
Assert.NotNull(video);
|
||||
|
||||
Assert.AreEqual("533ec6a7c3a368544800556f", video.Id);
|
||||
Assert.AreEqual("en", video.Iso_639_1);
|
||||
Assert.AreEqual("7EgVRvG2mM0", video.Key);
|
||||
Assert.AreEqual("A Good Day To Die Hard Official Trailer", video.Name);
|
||||
Assert.AreEqual("YouTube", video.Site);
|
||||
Assert.AreEqual(720, video.Size);
|
||||
Assert.AreEqual("Trailer", video.Type);
|
||||
Assert.Equal("533ec6a7c3a368544800556f", video.Id);
|
||||
Assert.Equal("en", video.Iso_639_1);
|
||||
Assert.Equal("7EgVRvG2mM0", video.Key);
|
||||
Assert.Equal("A Good Day To Die Hard Official Trailer", video.Name);
|
||||
Assert.Equal("YouTube", video.Site);
|
||||
Assert.Equal(720, video.Size);
|
||||
Assert.Equal("Trailer", video.Type);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesGetMovieTranslations()
|
||||
{
|
||||
TranslationsContainer resp = _config.Client.GetMovieTranslationsAsync(IdHelper.AGoodDayToDieHard).Result;
|
||||
Assert.IsNotNull(resp);
|
||||
Assert.NotNull(resp);
|
||||
|
||||
Translation translation = resp.Translations.SingleOrDefault(s => s.EnglishName == "German");
|
||||
Assert.IsNotNull(translation);
|
||||
Assert.NotNull(translation);
|
||||
|
||||
Assert.AreEqual("German", translation.EnglishName);
|
||||
Assert.AreEqual("de", translation.Iso_639_1);
|
||||
Assert.AreEqual("Deutsch", translation.Name);
|
||||
Assert.Equal("German", translation.EnglishName);
|
||||
Assert.Equal("de", translation.Iso_639_1);
|
||||
Assert.Equal("Deutsch", translation.Name);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesGetMovieSimilarMovies()
|
||||
{
|
||||
SearchContainer<MovieResult> resp = _config.Client.GetMovieSimilarAsync(IdHelper.AGoodDayToDieHard).Result;
|
||||
Assert.IsNotNull(resp);
|
||||
Assert.NotNull(resp);
|
||||
|
||||
SearchContainer<MovieResult> respGerman = _config.Client.GetMovieSimilarAsync(IdHelper.AGoodDayToDieHard, language: "de").Result;
|
||||
Assert.IsNotNull(respGerman);
|
||||
Assert.NotNull(respGerman);
|
||||
|
||||
Assert.AreEqual(resp.Results.Count, respGerman.Results.Count);
|
||||
Assert.Equal(resp.Results.Count, respGerman.Results.Count);
|
||||
|
||||
int differentTitles = 0;
|
||||
for (int i = 0; i < resp.Results.Count; i++)
|
||||
{
|
||||
Assert.AreEqual(resp.Results[i].Id, respGerman.Results[i].Id);
|
||||
Assert.Equal(resp.Results[i].Id, respGerman.Results[i].Id);
|
||||
|
||||
// At least one title should be different, as German is a big language and they dub all their titles.
|
||||
differentTitles++;
|
||||
}
|
||||
|
||||
Assert.IsTrue(differentTitles > 0);
|
||||
Assert.True(differentTitles > 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesGetMovieReviews()
|
||||
{
|
||||
SearchContainer<Review> resp = _config.Client.GetMovieReviewsAsync(IdHelper.TheDarkKnightRises).Result;
|
||||
Assert.IsNotNull(resp);
|
||||
Assert.NotNull(resp);
|
||||
|
||||
Assert.AreNotEqual(0, resp.Results.Count);
|
||||
Assert.IsNotNull(resp.Results[0].Content);
|
||||
Assert.NotEqual(0, resp.Results.Count);
|
||||
Assert.NotNull(resp.Results[0].Content);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesGetMovieLists()
|
||||
{
|
||||
//GetMovieListsAsync(int id, string language, int page = -1)
|
||||
SearchContainer<ListResult> resp = _config.Client.GetMovieListsAsync(IdHelper.AGoodDayToDieHard).Result;
|
||||
Assert.IsNotNull(resp);
|
||||
Assert.NotNull(resp);
|
||||
|
||||
SearchContainer<ListResult> respPage2 = _config.Client.GetMovieListsAsync(IdHelper.AGoodDayToDieHard, 2).Result;
|
||||
Assert.IsNotNull(respPage2);
|
||||
Assert.NotNull(respPage2);
|
||||
|
||||
Assert.AreEqual(1, resp.Page);
|
||||
Assert.AreEqual(2, respPage2.Page);
|
||||
Assert.AreEqual(resp.TotalResults, resp.TotalResults);
|
||||
Assert.Equal(1, resp.Page);
|
||||
Assert.Equal(2, respPage2.Page);
|
||||
Assert.Equal(resp.TotalResults, resp.TotalResults);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesGetMovieChanges()
|
||||
{
|
||||
//GetMovieChangesAsync(int id, DateTime? startDate = null, DateTime? endDate = null)
|
||||
// FindAsync latest changed title
|
||||
int latestChanged = _config.Client.GetMovieLatestAsync().Result.Id;
|
||||
int latestChanged = _config.Client.GetMovieLatestAsync().Sync().Id;
|
||||
|
||||
// Fetch changelog
|
||||
DateTime lower = DateTime.UtcNow.AddDays(-13);
|
||||
DateTime higher = DateTime.UtcNow.AddDays(1);
|
||||
List<Change> respRange = _config.Client.GetMovieChangesAsync(latestChanged, lower, higher).Result;
|
||||
|
||||
Assert.IsNotNull(respRange);
|
||||
Assert.IsTrue(respRange.Count > 0);
|
||||
Assert.NotNull(respRange);
|
||||
Assert.True(respRange.Count > 0);
|
||||
|
||||
// As TMDb works in days, we need to adjust our values also
|
||||
lower = lower.AddDays(-1);
|
||||
@ -373,12 +361,12 @@ namespace TMDbLibTests
|
||||
foreach (ChangeItem changeItem in change.Items)
|
||||
{
|
||||
DateTime date = changeItem.Time;
|
||||
Assert.IsTrue(lower <= date);
|
||||
Assert.IsTrue(date <= higher);
|
||||
Assert.True(lower <= date);
|
||||
Assert.True(date <= higher);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesImages()
|
||||
{
|
||||
// Get config
|
||||
@ -387,11 +375,11 @@ namespace TMDbLibTests
|
||||
// Test image url generator
|
||||
ImagesWithId images = _config.Client.GetMovieImagesAsync(IdHelper.AGoodDayToDieHard).Result;
|
||||
|
||||
Assert.AreEqual(IdHelper.AGoodDayToDieHard, images.Id);
|
||||
Assert.Equal(IdHelper.AGoodDayToDieHard, images.Id);
|
||||
TestImagesHelpers.TestImages(_config, images);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesList()
|
||||
{
|
||||
//GetMovieListAsync(MovieListType type, string language, int page = -1)
|
||||
@ -399,28 +387,28 @@ namespace TMDbLibTests
|
||||
{
|
||||
SearchContainer<MovieResult> list = _config.Client.GetMovieListAsync(type).Result;
|
||||
|
||||
Assert.IsNotNull(list);
|
||||
Assert.IsTrue(list.Results.Count > 0);
|
||||
Assert.AreEqual(1, list.Page);
|
||||
Assert.NotNull(list);
|
||||
Assert.True(list.Results.Count > 0);
|
||||
Assert.Equal(1, list.Page);
|
||||
|
||||
SearchContainer<MovieResult> listPage2 = _config.Client.GetMovieListAsync(type, 2).Result;
|
||||
|
||||
Assert.IsNotNull(listPage2);
|
||||
Assert.IsTrue(listPage2.Results.Count > 0);
|
||||
Assert.AreEqual(2, listPage2.Page);
|
||||
Assert.NotNull(listPage2);
|
||||
Assert.True(listPage2.Results.Count > 0);
|
||||
Assert.Equal(2, listPage2.Page);
|
||||
|
||||
SearchContainer<MovieResult> listDe = _config.Client.GetMovieListAsync(type, "de").Result;
|
||||
|
||||
Assert.IsNotNull(listDe);
|
||||
Assert.IsTrue(listDe.Results.Count > 0);
|
||||
Assert.AreEqual(1, listDe.Page);
|
||||
Assert.NotNull(listDe);
|
||||
Assert.True(listDe.Results.Count > 0);
|
||||
Assert.Equal(1, listDe.Page);
|
||||
|
||||
// At least one title should differ
|
||||
Assert.IsTrue(list.Results.Any(s => listDe.Results.Any(x => x.Title != s.Title)));
|
||||
Assert.True(list.Results.Any(s => listDe.Results.Any(x => x.Title != s.Title)));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesAccountStateFavoriteSet()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
@ -428,7 +416,7 @@ namespace TMDbLibTests
|
||||
|
||||
// Remove the favourite
|
||||
if (accountState.Favorite)
|
||||
_config.Client.AccountChangeFavoriteStatusAsync(MediaType.Movie, IdHelper.MadMaxFuryRoad, false).Wait();
|
||||
_config.Client.AccountChangeFavoriteStatusAsync(MediaType.Movie, IdHelper.MadMaxFuryRoad, false).Sync();
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
@ -436,22 +424,22 @@ namespace TMDbLibTests
|
||||
// Test that the movie is NOT favourited
|
||||
accountState = _config.Client.GetMovieAccountStateAsync(IdHelper.MadMaxFuryRoad).Result;
|
||||
|
||||
Assert.AreEqual(IdHelper.MadMaxFuryRoad, accountState.Id);
|
||||
Assert.IsFalse(accountState.Favorite);
|
||||
Assert.Equal(IdHelper.MadMaxFuryRoad, accountState.Id);
|
||||
Assert.False(accountState.Favorite);
|
||||
|
||||
// Favourite the movie
|
||||
_config.Client.AccountChangeFavoriteStatusAsync(MediaType.Movie, IdHelper.MadMaxFuryRoad, true).Wait();
|
||||
_config.Client.AccountChangeFavoriteStatusAsync(MediaType.Movie, IdHelper.MadMaxFuryRoad, true).Sync();
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
// Test that the movie IS favourited
|
||||
accountState = _config.Client.GetMovieAccountStateAsync(IdHelper.MadMaxFuryRoad).Result;
|
||||
Assert.AreEqual(IdHelper.MadMaxFuryRoad, accountState.Id);
|
||||
Assert.IsTrue(accountState.Favorite);
|
||||
Assert.Equal(IdHelper.MadMaxFuryRoad, accountState.Id);
|
||||
Assert.True(accountState.Favorite);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesAccountStateWatchlistSet()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
@ -459,7 +447,7 @@ namespace TMDbLibTests
|
||||
|
||||
// Remove the watchlist
|
||||
if (accountState.Watchlist)
|
||||
_config.Client.AccountChangeWatchlistStatusAsync(MediaType.Movie, IdHelper.MadMaxFuryRoad, false).Wait();
|
||||
_config.Client.AccountChangeWatchlistStatusAsync(MediaType.Movie, IdHelper.MadMaxFuryRoad, false).Sync();
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
@ -467,22 +455,22 @@ namespace TMDbLibTests
|
||||
// Test that the movie is NOT watchlisted
|
||||
accountState = _config.Client.GetMovieAccountStateAsync(IdHelper.MadMaxFuryRoad).Result;
|
||||
|
||||
Assert.AreEqual(IdHelper.MadMaxFuryRoad, accountState.Id);
|
||||
Assert.IsFalse(accountState.Watchlist);
|
||||
Assert.Equal(IdHelper.MadMaxFuryRoad, accountState.Id);
|
||||
Assert.False(accountState.Watchlist);
|
||||
|
||||
// Watchlist the movie
|
||||
_config.Client.AccountChangeWatchlistStatusAsync(MediaType.Movie, IdHelper.MadMaxFuryRoad, true).Wait();
|
||||
_config.Client.AccountChangeWatchlistStatusAsync(MediaType.Movie, IdHelper.MadMaxFuryRoad, true).Sync();
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
// Test that the movie IS watchlisted
|
||||
accountState = _config.Client.GetMovieAccountStateAsync(IdHelper.MadMaxFuryRoad).Result;
|
||||
Assert.AreEqual(IdHelper.MadMaxFuryRoad, accountState.Id);
|
||||
Assert.IsTrue(accountState.Watchlist);
|
||||
Assert.Equal(IdHelper.MadMaxFuryRoad, accountState.Id);
|
||||
Assert.True(accountState.Watchlist);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesAccountStateRatingSet()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
@ -491,7 +479,7 @@ namespace TMDbLibTests
|
||||
// Remove the rating
|
||||
if (accountState.Rating.HasValue)
|
||||
{
|
||||
Assert.IsTrue(_config.Client.MovieRemoveRatingAsync(IdHelper.MadMaxFuryRoad).Result);
|
||||
Assert.True(_config.Client.MovieRemoveRatingAsync(IdHelper.MadMaxFuryRoad).Result);
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
@ -500,136 +488,136 @@ namespace TMDbLibTests
|
||||
// Test that the movie is NOT rated
|
||||
accountState = _config.Client.GetMovieAccountStateAsync(IdHelper.MadMaxFuryRoad).Result;
|
||||
|
||||
Assert.AreEqual(IdHelper.MadMaxFuryRoad, accountState.Id);
|
||||
Assert.IsFalse(accountState.Rating.HasValue);
|
||||
Assert.Equal(IdHelper.MadMaxFuryRoad, accountState.Id);
|
||||
Assert.False(accountState.Rating.HasValue);
|
||||
|
||||
// Rate the movie
|
||||
_config.Client.MovieSetRatingAsync(IdHelper.MadMaxFuryRoad, 5).Wait();
|
||||
_config.Client.MovieSetRatingAsync(IdHelper.MadMaxFuryRoad, 5).Sync();
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
// Test that the movie IS rated
|
||||
accountState = _config.Client.GetMovieAccountStateAsync(IdHelper.MadMaxFuryRoad).Result;
|
||||
Assert.AreEqual(IdHelper.MadMaxFuryRoad, accountState.Id);
|
||||
Assert.IsTrue(accountState.Rating.HasValue);
|
||||
Assert.Equal(IdHelper.MadMaxFuryRoad, accountState.Id);
|
||||
Assert.True(accountState.Rating.HasValue);
|
||||
|
||||
// Remove the rating
|
||||
Assert.IsTrue(_config.Client.MovieRemoveRatingAsync(IdHelper.MadMaxFuryRoad).Result);
|
||||
Assert.True(_config.Client.MovieRemoveRatingAsync(IdHelper.MadMaxFuryRoad).Result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesSetRatingBadRating()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
Assert.IsFalse(_config.Client.MovieSetRatingAsync(IdHelper.Avatar, 7.1).Result);
|
||||
Assert.False(_config.Client.MovieSetRatingAsync(IdHelper.Avatar, 7.1).Result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesSetRatingRatingOutOfBounds()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
Assert.IsFalse(_config.Client.MovieSetRatingAsync(IdHelper.Avatar, 10.5).Result);
|
||||
Assert.False(_config.Client.MovieSetRatingAsync(IdHelper.Avatar, 10.5).Result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesSetRatingRatingLowerBoundsTest()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
Assert.IsFalse(_config.Client.MovieSetRatingAsync(IdHelper.Avatar, 0).Result);
|
||||
Assert.False(_config.Client.MovieSetRatingAsync(IdHelper.Avatar, 0).Result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesSetRatingUserSession()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Ensure that the test movie has a different rating than our test rating
|
||||
var rating = _config.Client.GetMovieAccountStateAsync(IdHelper.Avatar).Result.Rating;
|
||||
Assert.IsNotNull(rating);
|
||||
Assert.NotNull(rating);
|
||||
|
||||
double originalRating = rating.Value;
|
||||
double newRating = Math.Abs(originalRating - 7.5) < double.Epsilon ? 2.5 : 7.5;
|
||||
|
||||
// Try changing the rating
|
||||
Assert.IsTrue(_config.Client.MovieSetRatingAsync(IdHelper.Avatar, newRating).Result);
|
||||
Assert.True(_config.Client.MovieSetRatingAsync(IdHelper.Avatar, newRating).Result);
|
||||
|
||||
// Allow TMDb to not cache our data
|
||||
Thread.Sleep(2000);
|
||||
|
||||
// Check if it worked
|
||||
Assert.AreEqual(newRating, _config.Client.GetMovieAccountStateAsync(IdHelper.Avatar).Result.Rating);
|
||||
Assert.Equal(newRating, _config.Client.GetMovieAccountStateAsync(IdHelper.Avatar).Result.Rating);
|
||||
|
||||
// Try changing it back to the previous rating
|
||||
Assert.IsTrue(_config.Client.MovieSetRatingAsync(IdHelper.Avatar, originalRating).Result);
|
||||
Assert.True(_config.Client.MovieSetRatingAsync(IdHelper.Avatar, originalRating).Result);
|
||||
|
||||
// Allow TMDb to not cache our data
|
||||
Thread.Sleep(2000);
|
||||
|
||||
// Check if it worked
|
||||
Assert.AreEqual(originalRating, _config.Client.GetMovieAccountStateAsync(IdHelper.Avatar).Result.Rating);
|
||||
Assert.Equal(originalRating, _config.Client.GetMovieAccountStateAsync(IdHelper.Avatar).Result.Rating);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesGetHtmlEncodedText()
|
||||
{
|
||||
Movie item = _config.Client.GetMovieAsync(IdHelper.Furious7, "de").Result;
|
||||
|
||||
Assert.IsNotNull(item);
|
||||
Assert.NotNull(item);
|
||||
|
||||
Assert.IsFalse(item.Overview.Contains("&"));
|
||||
Assert.False(item.Overview.Contains("&"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesGet()
|
||||
{
|
||||
Movie item = _config.Client.GetMovieAsync(IdHelper.AGoodDayToDieHard).Result;
|
||||
|
||||
Assert.IsNotNull(item);
|
||||
Assert.AreEqual(IdHelper.AGoodDayToDieHard, item.Id);
|
||||
Assert.AreEqual(IdHelper.AGoodDayToDieHardImdb, item.ImdbId);
|
||||
Assert.NotNull(item);
|
||||
Assert.Equal(IdHelper.AGoodDayToDieHard, item.Id);
|
||||
Assert.Equal(IdHelper.AGoodDayToDieHardImdb, item.ImdbId);
|
||||
|
||||
// Check all properties
|
||||
Assert.AreEqual("A Good Day to Die Hard", item.Title);
|
||||
Assert.AreEqual("A Good Day to Die Hard", item.OriginalTitle);
|
||||
Assert.AreEqual("en", item.OriginalLanguage);
|
||||
Assert.Equal("A Good Day to Die Hard", item.Title);
|
||||
Assert.Equal("A Good Day to Die Hard", item.OriginalTitle);
|
||||
Assert.Equal("en", item.OriginalLanguage);
|
||||
|
||||
Assert.AreEqual("Released", item.Status);
|
||||
Assert.AreEqual("Yippee Ki-Yay Mother Russia", item.Tagline);
|
||||
Assert.AreEqual("Iconoclastic, take-no-prisoners cop John McClane, finds himself for the first time on foreign soil after traveling to Moscow to help his wayward son Jack - unaware that Jack is really a highly-trained CIA operative out to stop a nuclear weapons heist. With the Russian underworld in pursuit, and battling a countdown to war, the two McClanes discover that their opposing methods make them unstoppable heroes.", item.Overview);
|
||||
Assert.AreEqual("http://www.diehardmovie.com/", item.Homepage);
|
||||
Assert.Equal("Released", item.Status);
|
||||
Assert.Equal("Yippee Ki-Yay Mother Russia", item.Tagline);
|
||||
Assert.Equal("Iconoclastic, take-no-prisoners cop John McClane, finds himself for the first time on foreign soil after traveling to Moscow to help his wayward son Jack - unaware that Jack is really a highly-trained CIA operative out to stop a nuclear weapons heist. With the Russian underworld in pursuit, and battling a countdown to war, the two McClanes discover that their opposing methods make them unstoppable heroes.", item.Overview);
|
||||
Assert.Equal("http://www.diehardmovie.com/", item.Homepage);
|
||||
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(item.BackdropPath), "item.BackdropPath was not a valid image path, was: " + item.BackdropPath);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(item.PosterPath), "item.PosterPath was not a valid image path, was: " + item.PosterPath);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.BackdropPath), "item.BackdropPath was not a valid image path, was: " + item.BackdropPath);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.PosterPath), "item.PosterPath was not a valid image path, was: " + item.PosterPath);
|
||||
|
||||
Assert.AreEqual(false, item.Adult);
|
||||
Assert.AreEqual(false, item.Video);
|
||||
Assert.Equal(false, item.Adult);
|
||||
Assert.Equal(false, item.Video);
|
||||
|
||||
Assert.IsNotNull(item.BelongsToCollection);
|
||||
Assert.AreEqual(1570, item.BelongsToCollection.Id);
|
||||
Assert.AreEqual("Die Hard Collection", item.BelongsToCollection.Name);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(item.BelongsToCollection.BackdropPath), "item.BelongsToCollection.BackdropPath was not a valid image path, was: " + item.BelongsToCollection.BackdropPath);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(item.BelongsToCollection.PosterPath), "item.BelongsToCollection.PosterPath was not a valid image path, was: " + item.BelongsToCollection.PosterPath);
|
||||
Assert.NotNull(item.BelongsToCollection);
|
||||
Assert.Equal(1570, item.BelongsToCollection.Id);
|
||||
Assert.Equal("Die Hard Collection", item.BelongsToCollection.Name);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.BelongsToCollection.BackdropPath), "item.BelongsToCollection.BackdropPath was not a valid image path, was: " + item.BelongsToCollection.BackdropPath);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.BelongsToCollection.PosterPath), "item.BelongsToCollection.PosterPath was not a valid image path, was: " + item.BelongsToCollection.PosterPath);
|
||||
|
||||
//Assert.AreEqual(1, item.BelongsToCollection.Count);
|
||||
//Assert.AreEqual(1570, item.BelongsToCollection[0].Id);
|
||||
//Assert.AreEqual("Die Hard Collection", item.BelongsToCollection[0].Name);
|
||||
//Assert.IsTrue(TestImagesHelpers.TestImagePath(item.BelongsToCollection[0].BackdropPath), "item.BelongsToCollection[0].BackdropPath was not a valid image path, was: " + item.BelongsToCollection[0].BackdropPath);
|
||||
//Assert.IsTrue(TestImagesHelpers.TestImagePath(item.BelongsToCollection[0].PosterPath), "item.BelongsToCollection[0].PosterPath was not a valid image path, was: " + item.BelongsToCollection[0].PosterPath);
|
||||
//Assert.Equal(1, item.BelongsToCollection.Count);
|
||||
//Assert.Equal(1570, item.BelongsToCollection[0].Id);
|
||||
//Assert.Equal("Die Hard Collection", item.BelongsToCollection[0].Name);
|
||||
//Assert.True(TestImagesHelpers.TestImagePath(item.BelongsToCollection[0].BackdropPath), "item.BelongsToCollection[0].BackdropPath was not a valid image path, was: " + item.BelongsToCollection[0].BackdropPath);
|
||||
//Assert.True(TestImagesHelpers.TestImagePath(item.BelongsToCollection[0].PosterPath), "item.BelongsToCollection[0].PosterPath was not a valid image path, was: " + item.BelongsToCollection[0].PosterPath);
|
||||
|
||||
Assert.AreEqual(2, item.Genres.Count);
|
||||
Assert.AreEqual(28, item.Genres[0].Id);
|
||||
Assert.AreEqual("Action", item.Genres[0].Name);
|
||||
Assert.AreEqual(53, item.Genres[1].Id);
|
||||
Assert.AreEqual("Thriller", item.Genres[1].Name);
|
||||
Assert.Equal(2, item.Genres.Count);
|
||||
Assert.Equal(28, item.Genres[0].Id);
|
||||
Assert.Equal("Action", item.Genres[0].Name);
|
||||
Assert.Equal(53, item.Genres[1].Id);
|
||||
Assert.Equal("Thriller", item.Genres[1].Name);
|
||||
|
||||
Assert.IsTrue(item.ReleaseDate > new DateTime(2013, 01, 01));
|
||||
Assert.AreEqual(304654182, item.Revenue);
|
||||
Assert.AreEqual(92000000, item.Budget);
|
||||
Assert.AreEqual(98, item.Runtime);
|
||||
Assert.True(item.ReleaseDate > new DateTime(2013, 01, 01));
|
||||
Assert.Equal(304654182, item.Revenue);
|
||||
Assert.Equal(92000000, item.Budget);
|
||||
Assert.Equal(98, item.Runtime);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestMoviesExtrasAccountState()
|
||||
{
|
||||
// Test the custom parsing code for Account State rating
|
||||
@ -638,7 +626,7 @@ namespace TMDbLibTests
|
||||
Movie movie = _config.Client.GetMovieAsync(IdHelper.TheDarkKnightRises, MovieMethods.AccountStates).Result;
|
||||
if (movie.AccountStates == null || !movie.AccountStates.Rating.HasValue)
|
||||
{
|
||||
_config.Client.MovieSetRatingAsync(IdHelper.TheDarkKnightRises, 5).Wait();
|
||||
_config.Client.MovieSetRatingAsync(IdHelper.TheDarkKnightRises, 5).Sync();
|
||||
|
||||
// Allow TMDb to update cache
|
||||
Thread.Sleep(2000);
|
||||
@ -646,9 +634,9 @@ namespace TMDbLibTests
|
||||
movie = _config.Client.GetMovieAsync(IdHelper.TheDarkKnightRises, MovieMethods.AccountStates).Result;
|
||||
}
|
||||
|
||||
Assert.IsNotNull(movie.AccountStates);
|
||||
Assert.IsTrue(movie.AccountStates.Rating.HasValue);
|
||||
Assert.IsTrue(Math.Abs(movie.AccountStates.Rating.Value - 5) < double.Epsilon);
|
||||
Assert.NotNull(movie.AccountStates);
|
||||
Assert.True(movie.AccountStates.Rating.HasValue);
|
||||
Assert.True(Math.Abs(movie.AccountStates.Rating.Value - 5) < double.Epsilon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,34 +1,27 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.TvShows;
|
||||
using TMDbLibTests.Helpers;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientNetworkTests : TestBase
|
||||
{
|
||||
private TestConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public override void Initiator()
|
||||
public ClientNetworkTests()
|
||||
{
|
||||
base.Initiator();
|
||||
|
||||
_config = new TestConfig();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestNetworkGetById()
|
||||
{
|
||||
Network network = _config.Client.GetNetworkAsync(IdHelper.Hbo).Result;
|
||||
|
||||
Assert.IsNotNull(network);
|
||||
Assert.AreEqual("HBO", network.Name);
|
||||
Assert.AreEqual(IdHelper.Hbo, network.Id);
|
||||
Assert.NotNull(network);
|
||||
Assert.Equal("HBO", network.Name);
|
||||
Assert.Equal(IdHelper.Hbo, network.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Changes;
|
||||
using TMDbLib.Objects.People;
|
||||
using TMDbLib.Objects.General;
|
||||
@ -10,39 +10,27 @@ using TMDbLibTests.JsonHelpers;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientPersonTests : TestBase
|
||||
{
|
||||
private static Dictionary<PersonMethods, Func<Person, object>> _methods;
|
||||
private TestConfig _config;
|
||||
private readonly TestConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public override void Initiator()
|
||||
public ClientPersonTests()
|
||||
{
|
||||
base.Initiator();
|
||||
|
||||
_config = new TestConfig();
|
||||
|
||||
_methods = new Dictionary<PersonMethods, Func<Person, object>>
|
||||
{
|
||||
[PersonMethods.MovieCredits] = person => person.MovieCredits,
|
||||
[PersonMethods.TvCredits] = person => person.TvCredits,
|
||||
[PersonMethods.ExternalIds] = person => person.ExternalIds,
|
||||
[PersonMethods.Images] = person => person.Images,
|
||||
[PersonMethods.TaggedImages] = person => person.TaggedImages,
|
||||
[PersonMethods.Changes] = person => person.Changes
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on test class initialization
|
||||
/// </summary>
|
||||
[ClassInitialize]
|
||||
public static void InitialInitiator(TestContext context)
|
||||
{
|
||||
_methods = new Dictionary<PersonMethods, Func<Person, object>>();
|
||||
_methods[PersonMethods.MovieCredits] = person => person.MovieCredits;
|
||||
_methods[PersonMethods.TvCredits] = person => person.TvCredits;
|
||||
_methods[PersonMethods.ExternalIds] = person => person.ExternalIds;
|
||||
_methods[PersonMethods.Images] = person => person.Images;
|
||||
_methods[PersonMethods.TaggedImages] = person => person.TaggedImages;
|
||||
_methods[PersonMethods.Changes] = person => person.Changes;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestPersonsExtrasNone()
|
||||
{
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
@ -50,18 +38,18 @@ namespace TMDbLibTests
|
||||
|
||||
Person person = _config.Client.GetPersonAsync(IdHelper.BruceWillis).Result;
|
||||
|
||||
Assert.IsNotNull(person);
|
||||
Assert.NotNull(person);
|
||||
|
||||
Assert.AreEqual("Bruce Willis", person.Name);
|
||||
Assert.Equal("Bruce Willis", person.Name);
|
||||
|
||||
// Test all extras, ensure none of them exist
|
||||
foreach (Func<Person, object> selector in _methods.Values)
|
||||
{
|
||||
Assert.IsNull(selector(person));
|
||||
Assert.Null(selector(person));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestPersonsExtrasExclusive()
|
||||
{
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
@ -70,7 +58,7 @@ namespace TMDbLibTests
|
||||
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetPersonAsync(id, extras).Result, IdHelper.BruceWillis);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestPersonsExtrasAll()
|
||||
{
|
||||
PersonMethods combinedEnum = _methods.Keys.Aggregate((methods, movieMethods) => methods | movieMethods);
|
||||
@ -79,135 +67,135 @@ namespace TMDbLibTests
|
||||
TestMethodsHelper.TestAllNotNull(_methods, item);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestPersonsGet()
|
||||
{
|
||||
Person item = _config.Client.GetPersonAsync(IdHelper.BruceWillis).Result;
|
||||
|
||||
Assert.IsNotNull(item);
|
||||
Assert.AreEqual(false, item.Adult);
|
||||
Assert.IsNotNull(item.Biography);
|
||||
Assert.AreEqual(new DateTime(1955, 3, 19), item.Birthday);
|
||||
Assert.IsFalse(item.Deathday.HasValue);
|
||||
Assert.AreEqual("http://www.b-willis.com/", item.Homepage);
|
||||
Assert.AreEqual(62, item.Id);
|
||||
Assert.AreEqual("nm0000246", item.ImdbId);
|
||||
Assert.AreEqual("Bruce Willis", item.Name);
|
||||
Assert.AreEqual("Idar-Oberstein, Germany", item.PlaceOfBirth);
|
||||
Assert.IsTrue(item.Popularity > 0);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(item.ProfilePath), "item.ProfilePath was not a valid image path, was: " + item.ProfilePath);
|
||||
Assert.NotNull(item);
|
||||
Assert.Equal(false, item.Adult);
|
||||
Assert.NotNull(item.Biography);
|
||||
Assert.Equal(new DateTime(1955, 3, 19), item.Birthday);
|
||||
Assert.False(item.Deathday.HasValue);
|
||||
Assert.Equal("http://www.b-willis.com/", item.Homepage);
|
||||
Assert.Equal(62, item.Id);
|
||||
Assert.Equal("nm0000246", item.ImdbId);
|
||||
Assert.Equal("Bruce Willis", item.Name);
|
||||
Assert.Equal("Idar-Oberstein, Germany", item.PlaceOfBirth);
|
||||
Assert.True(item.Popularity > 0);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.ProfilePath), "item.ProfilePath was not a valid image path, was: " + item.ProfilePath);
|
||||
|
||||
Assert.IsNotNull(item.AlsoKnownAs);
|
||||
Assert.AreEqual(2, item.AlsoKnownAs.Count);
|
||||
Assert.IsTrue(item.AlsoKnownAs.Contains("Брюс Уиллис"));
|
||||
Assert.IsTrue(item.AlsoKnownAs.Contains("브루스 윌리스"));
|
||||
Assert.NotNull(item.AlsoKnownAs);
|
||||
Assert.Equal(2, item.AlsoKnownAs.Count);
|
||||
Assert.True(item.AlsoKnownAs.Contains("Брюс Уиллис"));
|
||||
Assert.True(item.AlsoKnownAs.Contains("브루스 윌리스"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestPersonsGetPersonTvCredits()
|
||||
{
|
||||
TvCredits item = _config.Client.GetPersonTvCreditsAsync(IdHelper.BruceWillis).Result;
|
||||
|
||||
Assert.IsNotNull(item);
|
||||
Assert.IsNotNull(item.Cast);
|
||||
Assert.IsNotNull(item.Crew);
|
||||
Assert.NotNull(item);
|
||||
Assert.NotNull(item.Cast);
|
||||
Assert.NotNull(item.Crew);
|
||||
|
||||
Assert.AreEqual(IdHelper.BruceWillis, item.Id);
|
||||
Assert.Equal(IdHelper.BruceWillis, item.Id);
|
||||
|
||||
TvRole cast = item.Cast.SingleOrDefault(s => s.Character == "David Addison Jr.");
|
||||
Assert.IsNotNull(cast);
|
||||
Assert.AreEqual("David Addison Jr.", cast.Character);
|
||||
Assert.AreEqual("52571e7f19c2957114107d48", cast.CreditId);
|
||||
Assert.AreEqual(71, cast.EpisodeCount);
|
||||
Assert.AreEqual(new DateTime(1985, 3, 3), cast.FirstAirDate);
|
||||
Assert.AreEqual(1998, cast.Id);
|
||||
Assert.AreEqual("Moonlighting", cast.Name);
|
||||
Assert.AreEqual("Moonlighting", cast.OriginalName);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(cast.PosterPath), "cast.PosterPath was not a valid image path, was: " + cast.PosterPath);
|
||||
Assert.NotNull(cast);
|
||||
Assert.Equal("David Addison Jr.", cast.Character);
|
||||
Assert.Equal("52571e7f19c2957114107d48", cast.CreditId);
|
||||
Assert.Equal(71, cast.EpisodeCount);
|
||||
Assert.Equal(new DateTime(1985, 3, 3), cast.FirstAirDate);
|
||||
Assert.Equal(1998, cast.Id);
|
||||
Assert.Equal("Moonlighting", cast.Name);
|
||||
Assert.Equal("Moonlighting", cast.OriginalName);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(cast.PosterPath), "cast.PosterPath was not a valid image path, was: " + cast.PosterPath);
|
||||
|
||||
TvJob job = item.Crew.SingleOrDefault(s => s.CreditId == "525826eb760ee36aaa81b23b");
|
||||
Assert.IsNotNull(job);
|
||||
Assert.AreEqual("525826eb760ee36aaa81b23b", job.CreditId);
|
||||
Assert.AreEqual("Production", job.Department);
|
||||
Assert.AreEqual(37, job.EpisodeCount);
|
||||
Assert.AreEqual(new DateTime(1996, 9, 23), job.FirstAirDate);
|
||||
Assert.AreEqual(13297, job.Id);
|
||||
Assert.AreEqual("Producer", job.Job);
|
||||
Assert.AreEqual("Bruno the Kid", job.Name);
|
||||
Assert.AreEqual("Bruno the Kid", job.OriginalName);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(job.PosterPath), "job.PosterPath was not a valid image path, was: " + job.PosterPath);
|
||||
Assert.NotNull(job);
|
||||
Assert.Equal("525826eb760ee36aaa81b23b", job.CreditId);
|
||||
Assert.Equal("Production", job.Department);
|
||||
Assert.Equal(37, job.EpisodeCount);
|
||||
Assert.Equal(new DateTime(1996, 9, 23), job.FirstAirDate);
|
||||
Assert.Equal(13297, job.Id);
|
||||
Assert.Equal("Producer", job.Job);
|
||||
Assert.Equal("Bruno the Kid", job.Name);
|
||||
Assert.Equal("Bruno the Kid", job.OriginalName);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(job.PosterPath), "job.PosterPath was not a valid image path, was: " + job.PosterPath);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestPersonsGetPersonMovieCredits()
|
||||
{
|
||||
MovieCredits item = _config.Client.GetPersonMovieCreditsAsync(IdHelper.BruceWillis).Result;
|
||||
|
||||
Assert.IsNotNull(item);
|
||||
Assert.IsNotNull(item.Cast);
|
||||
Assert.IsNotNull(item.Crew);
|
||||
Assert.NotNull(item);
|
||||
Assert.NotNull(item.Cast);
|
||||
Assert.NotNull(item.Crew);
|
||||
|
||||
Assert.AreEqual(IdHelper.BruceWillis, item.Id);
|
||||
Assert.Equal(IdHelper.BruceWillis, item.Id);
|
||||
|
||||
MovieRole cast = item.Cast.SingleOrDefault(s => s.CreditId == "52fe4329c3a36847f803f193");
|
||||
Assert.IsNotNull(cast);
|
||||
Assert.AreEqual(false, cast.Adult);
|
||||
Assert.AreEqual("Lieutenant Muldoon", cast.Character);
|
||||
Assert.AreEqual("52fe4329c3a36847f803f193", cast.CreditId);
|
||||
Assert.AreEqual(1992, cast.Id);
|
||||
Assert.AreEqual("Planet Terror", cast.OriginalTitle);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(cast.PosterPath), "cast.PosterPath was not a valid image path, was: " + cast.PosterPath);
|
||||
Assert.AreEqual(new DateTime(2007, 4, 6), cast.ReleaseDate);
|
||||
Assert.AreEqual("Planet Terror", cast.Title);
|
||||
Assert.NotNull(cast);
|
||||
Assert.Equal(false, cast.Adult);
|
||||
Assert.Equal("Lieutenant Muldoon", cast.Character);
|
||||
Assert.Equal("52fe4329c3a36847f803f193", cast.CreditId);
|
||||
Assert.Equal(1992, cast.Id);
|
||||
Assert.Equal("Planet Terror", cast.OriginalTitle);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(cast.PosterPath), "cast.PosterPath was not a valid image path, was: " + cast.PosterPath);
|
||||
Assert.Equal(new DateTime(2007, 4, 6), cast.ReleaseDate);
|
||||
Assert.Equal("Planet Terror", cast.Title);
|
||||
|
||||
MovieJob job = item.Crew.SingleOrDefault(s => s.CreditId == "52fe42fec3a36847f8032887");
|
||||
Assert.IsNotNull(job);
|
||||
Assert.AreEqual(false, job.Adult);
|
||||
Assert.AreEqual("52fe42fec3a36847f8032887", job.CreditId);
|
||||
Assert.AreEqual("Production", job.Department);
|
||||
Assert.AreEqual(1571, job.Id);
|
||||
Assert.AreEqual("Producer", job.Job);
|
||||
Assert.AreEqual(new DateTime(2007, 6, 20), job.ReleaseDate);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(job.PosterPath), "job.PosterPath was not a valid image path, was: " + job.PosterPath);
|
||||
Assert.AreEqual("Live Free or Die Hard", job.Title);
|
||||
Assert.AreEqual("Live Free or Die Hard", job.OriginalTitle);
|
||||
MovieJob job = item.Crew.SingleOrDefault(s => s.CreditId == "52fe432ec3a36847f8040603");
|
||||
Assert.NotNull(job);
|
||||
Assert.Equal(false, job.Adult);
|
||||
Assert.Equal("52fe432ec3a36847f8040603", job.CreditId);
|
||||
Assert.Equal("Production", job.Department);
|
||||
Assert.Equal(2026, job.Id);
|
||||
Assert.Equal("Producer", job.Job);
|
||||
Assert.Equal(new DateTime(2005, 3, 9), job.ReleaseDate);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(job.PosterPath), "job.PosterPath was not a valid image path, was: " + job.PosterPath);
|
||||
Assert.Equal("Hostage", job.Title);
|
||||
Assert.Equal("Hostage", job.OriginalTitle);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestPersonsGetPersonExternalIds()
|
||||
{
|
||||
ExternalIds item = _config.Client.GetPersonExternalIdsAsync(IdHelper.BruceWillis).Result;
|
||||
|
||||
Assert.IsNotNull(item);
|
||||
Assert.NotNull(item);
|
||||
|
||||
Assert.AreEqual(IdHelper.BruceWillis, item.Id);
|
||||
Assert.AreEqual("nm0000246", item.ImdbId);
|
||||
Assert.AreEqual("/m/0h7pj", item.FreebaseMid);
|
||||
Assert.AreEqual("/en/bruce_willis", item.FreebaseId);
|
||||
Assert.IsNull(item.TvdbId);
|
||||
Assert.AreEqual("10183", item.TvrageId);
|
||||
Assert.Equal(IdHelper.BruceWillis, item.Id);
|
||||
Assert.Equal("nm0000246", item.ImdbId);
|
||||
Assert.Equal("/m/0h7pj", item.FreebaseMid);
|
||||
Assert.Equal("/en/bruce_willis", item.FreebaseId);
|
||||
Assert.Null(item.TvdbId);
|
||||
Assert.Equal("10183", item.TvrageId);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestPersonsGetPersonCredits()
|
||||
{
|
||||
//GetPersonCredits(int id, string language)
|
||||
MovieCredits resp = _config.Client.GetPersonMovieCreditsAsync(IdHelper.BruceWillis).Result;
|
||||
Assert.IsNotNull(resp);
|
||||
Assert.NotNull(resp);
|
||||
|
||||
MovieCredits respItalian = _config.Client.GetPersonMovieCreditsAsync(IdHelper.BruceWillis, "it").Result;
|
||||
Assert.IsNotNull(respItalian);
|
||||
Assert.NotNull(respItalian);
|
||||
|
||||
Assert.AreEqual(resp.Cast.Count, respItalian.Cast.Count);
|
||||
Assert.AreEqual(resp.Crew.Count, respItalian.Crew.Count);
|
||||
Assert.AreEqual(resp.Id, respItalian.Id);
|
||||
Assert.Equal(resp.Cast.Count, respItalian.Cast.Count);
|
||||
Assert.Equal(resp.Crew.Count, respItalian.Crew.Count);
|
||||
Assert.Equal(resp.Id, respItalian.Id);
|
||||
|
||||
// There must be at least one movie with a different title
|
||||
bool allTitlesIdentical = true;
|
||||
for (int index = 0; index < resp.Cast.Count; index++)
|
||||
{
|
||||
Assert.AreEqual(resp.Cast[index].Id, respItalian.Cast[index].Id);
|
||||
Assert.AreEqual(resp.Cast[index].OriginalTitle, respItalian.Cast[index].OriginalTitle);
|
||||
Assert.Equal(resp.Cast[index].Id, respItalian.Cast[index].Id);
|
||||
Assert.Equal(resp.Cast[index].OriginalTitle, respItalian.Cast[index].OriginalTitle);
|
||||
|
||||
if (resp.Cast[index].Title != respItalian.Cast[index].Title)
|
||||
allTitlesIdentical = false;
|
||||
@ -215,30 +203,30 @@ namespace TMDbLibTests
|
||||
|
||||
for (int index = 0; index < resp.Crew.Count; index++)
|
||||
{
|
||||
Assert.AreEqual(resp.Crew[index].Id, respItalian.Crew[index].Id);
|
||||
Assert.AreEqual(resp.Crew[index].OriginalTitle, respItalian.Crew[index].OriginalTitle);
|
||||
Assert.Equal(resp.Crew[index].Id, respItalian.Crew[index].Id);
|
||||
Assert.Equal(resp.Crew[index].OriginalTitle, respItalian.Crew[index].OriginalTitle);
|
||||
|
||||
if (resp.Crew[index].Title != respItalian.Crew[index].Title)
|
||||
allTitlesIdentical = false;
|
||||
}
|
||||
|
||||
Assert.IsFalse(allTitlesIdentical);
|
||||
Assert.False(allTitlesIdentical);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestPersonsGetPersonChanges()
|
||||
{
|
||||
//GetPersonChangesAsync(int id, DateTime? startDate = null, DateTime? endDate = null)
|
||||
// FindAsync latest changed person
|
||||
int latestChanged = _config.Client.GetChangesPeopleAsync().Result.Results.First().Id;
|
||||
int latestChanged = _config.Client.GetChangesPeopleAsync().Sync().Results.First().Id;
|
||||
|
||||
// Fetch changelog
|
||||
DateTime lower = DateTime.UtcNow.AddDays(-14);
|
||||
DateTime higher = DateTime.UtcNow;
|
||||
List<Change> respRange = _config.Client.GetPersonChangesAsync(latestChanged, lower, higher).Result;
|
||||
|
||||
Assert.IsNotNull(respRange);
|
||||
Assert.IsTrue(respRange.Count > 0);
|
||||
Assert.NotNull(respRange);
|
||||
Assert.True(respRange.Count > 0);
|
||||
|
||||
// As TMDb works in days, we need to adjust our values also
|
||||
lower = lower.AddDays(-1);
|
||||
@ -248,12 +236,12 @@ namespace TMDbLibTests
|
||||
foreach (ChangeItem changeItem in change.Items)
|
||||
{
|
||||
DateTime date = changeItem.Time;
|
||||
Assert.IsTrue(lower <= date);
|
||||
Assert.IsTrue(date <= higher);
|
||||
Assert.True(lower <= date);
|
||||
Assert.True(date <= higher);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestPersonsImages()
|
||||
{
|
||||
// Get config
|
||||
@ -262,26 +250,26 @@ namespace TMDbLibTests
|
||||
// Get images
|
||||
ProfileImages images = _config.Client.GetPersonImagesAsync(IdHelper.BruceWillis).Result;
|
||||
|
||||
Assert.IsNotNull(images);
|
||||
Assert.IsNotNull(images.Profiles);
|
||||
Assert.AreEqual(IdHelper.BruceWillis, images.Id);
|
||||
Assert.NotNull(images);
|
||||
Assert.NotNull(images.Profiles);
|
||||
Assert.Equal(IdHelper.BruceWillis, images.Id);
|
||||
|
||||
// Test image url generator
|
||||
TestImagesHelpers.TestImages(_config, images);
|
||||
|
||||
ProfileImage image = images.Profiles.SingleOrDefault(s => s.FilePath == "/kI1OluWhLJk3pnR19VjOfABpnTY.jpg");
|
||||
|
||||
Assert.IsNotNull(image);
|
||||
Assert.IsTrue(Math.Abs(0.666666666666667 - image.AspectRatio) < double.Epsilon);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(image.FilePath), "image.FilePath was not a valid image path, was: " + image.FilePath);
|
||||
Assert.AreEqual(1500, image.Height);
|
||||
Assert.IsNull(image.Iso_639_1);
|
||||
Assert.AreEqual(1000, image.Width);
|
||||
Assert.IsTrue(image.VoteAverage > 0);
|
||||
Assert.IsTrue(image.VoteCount > 0);
|
||||
Assert.NotNull(image);
|
||||
Assert.True(Math.Abs(0.666666666666667 - image.AspectRatio) < double.Epsilon);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(image.FilePath), "image.FilePath was not a valid image path, was: " + image.FilePath);
|
||||
Assert.Equal(1500, image.Height);
|
||||
Assert.Null(image.Iso_639_1);
|
||||
Assert.Equal(1000, image.Width);
|
||||
Assert.True(image.VoteAverage > 0);
|
||||
Assert.True(image.VoteCount > 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestPersonsTaggedImages()
|
||||
{
|
||||
// Get config
|
||||
@ -292,78 +280,78 @@ namespace TMDbLibTests
|
||||
|
||||
SearchContainer<TaggedImage> images = _config.Client.GetPersonTaggedImagesAsync(IdHelper.BruceWillis, 1).Result;
|
||||
|
||||
Assert.IsNotNull(images);
|
||||
Assert.IsNotNull(images.Results);
|
||||
Assert.NotNull(images);
|
||||
Assert.NotNull(images.Results);
|
||||
|
||||
TaggedImage image = images.Results.SingleOrDefault(s => s.FilePath == "/my81Hjt7NpZhaMX9bHi4wVhFy0v.jpg");
|
||||
|
||||
Assert.IsNotNull(image);
|
||||
Assert.IsTrue(Math.Abs(1.77777777777778 - image.AspectRatio) < double.Epsilon);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(image.FilePath), "image.FilePath was not a valid image path, was: " + image.FilePath);
|
||||
Assert.AreEqual(1080, image.Height);
|
||||
Assert.AreEqual("4ea5d0792c058837cb000431", image.Id);
|
||||
Assert.IsNull(image.Iso_639_1);
|
||||
Assert.IsTrue(image.VoteAverage > 0);
|
||||
Assert.IsTrue(image.VoteCount > 0);
|
||||
Assert.AreEqual(1920, image.Width);
|
||||
Assert.AreEqual("backdrop", image.ImageType);
|
||||
Assert.AreEqual(MediaType.Movie, image.MediaType);
|
||||
Assert.NotNull(image);
|
||||
Assert.True(Math.Abs(1.77777777777778 - image.AspectRatio) < double.Epsilon);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(image.FilePath), "image.FilePath was not a valid image path, was: " + image.FilePath);
|
||||
Assert.Equal(1080, image.Height);
|
||||
Assert.Equal("4ea5d0792c058837cb000431", image.Id);
|
||||
Assert.Null(image.Iso_639_1);
|
||||
Assert.True(image.VoteAverage > 0);
|
||||
Assert.True(image.VoteCount > 0);
|
||||
Assert.Equal(1920, image.Width);
|
||||
Assert.Equal("backdrop", image.ImageType);
|
||||
Assert.Equal(MediaType.Movie, image.MediaType);
|
||||
|
||||
Assert.IsNotNull(image.Media);
|
||||
Assert.AreEqual(false, image.Media.Adult);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(image.Media.BackdropPath), "image.Media.BackdropPath was not a valid image path, was: " + image.Media.BackdropPath);
|
||||
Assert.AreEqual(187, image.Media.Id);
|
||||
Assert.AreEqual("en", image.Media.OriginalLanguage);
|
||||
Assert.AreEqual("Sin City", image.Media.OriginalTitle);
|
||||
Assert.AreEqual("Welcome to Sin City. This town beckons to the tough, the corrupt, the brokenhearted. Some call it dark… Hard-boiled. Then there are those who call it home — Crooked cops, sexy dames, desperate vigilantes. Some are seeking revenge, others lust after redemption, and then there are those hoping for a little of both. A universe of unlikely and reluctant heroes still trying to do the right thing in a city that refuses to care.", image.Media.Overview);
|
||||
Assert.AreEqual(new DateTime(2005, 3, 31), image.Media.ReleaseDate);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(image.Media.PosterPath), "image.Media.PosterPath was not a valid image path, was: " + image.Media.PosterPath);
|
||||
Assert.IsTrue(image.Media.Popularity > 0);
|
||||
Assert.AreEqual("Sin City", image.Media.Title);
|
||||
Assert.AreEqual(false, image.Media.Video);
|
||||
Assert.IsTrue(image.Media.VoteAverage > 0);
|
||||
Assert.IsTrue(image.Media.VoteCount > 0);
|
||||
Assert.NotNull(image.Media);
|
||||
Assert.Equal(false, image.Media.Adult);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(image.Media.BackdropPath), "image.Media.BackdropPath was not a valid image path, was: " + image.Media.BackdropPath);
|
||||
Assert.Equal(187, image.Media.Id);
|
||||
Assert.Equal("en", image.Media.OriginalLanguage);
|
||||
Assert.Equal("Sin City", image.Media.OriginalTitle);
|
||||
Assert.Equal("Welcome to Sin City. This town beckons to the tough, the corrupt, the brokenhearted. Some call it dark… Hard-boiled. Then there are those who call it home — Crooked cops, sexy dames, desperate vigilantes. Some are seeking revenge, others lust after redemption, and then there are those hoping for a little of both. A universe of unlikely and reluctant heroes still trying to do the right thing in a city that refuses to care.", image.Media.Overview);
|
||||
Assert.Equal(new DateTime(2005, 3, 31), image.Media.ReleaseDate);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(image.Media.PosterPath), "image.Media.PosterPath was not a valid image path, was: " + image.Media.PosterPath);
|
||||
Assert.True(image.Media.Popularity > 0);
|
||||
Assert.Equal("Sin City", image.Media.Title);
|
||||
Assert.Equal(false, image.Media.Video);
|
||||
Assert.True(image.Media.VoteAverage > 0);
|
||||
Assert.True(image.Media.VoteCount > 0);
|
||||
|
||||
Assert.IsNotNull(image.Media.GenreIds);
|
||||
Assert.AreEqual(3, image.Media.GenreIds.Count);
|
||||
Assert.IsTrue(image.Media.GenreIds.Contains(28));
|
||||
Assert.IsTrue(image.Media.GenreIds.Contains(53));
|
||||
Assert.IsTrue(image.Media.GenreIds.Contains(80));
|
||||
Assert.NotNull(image.Media.GenreIds);
|
||||
Assert.Equal(3, image.Media.GenreIds.Count);
|
||||
Assert.True(image.Media.GenreIds.Contains(28));
|
||||
Assert.True(image.Media.GenreIds.Contains(53));
|
||||
Assert.True(image.Media.GenreIds.Contains(80));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestPersonsList()
|
||||
{
|
||||
foreach (PersonListType type in Enum.GetValues(typeof(PersonListType)).OfType<PersonListType>())
|
||||
{
|
||||
SearchContainer<PersonResult> list = _config.Client.GetPersonListAsync(type).Result;
|
||||
|
||||
Assert.IsNotNull(list);
|
||||
Assert.IsTrue(list.Results.Count > 0);
|
||||
Assert.AreEqual(1, list.Page);
|
||||
Assert.NotNull(list);
|
||||
Assert.True(list.Results.Count > 0);
|
||||
Assert.Equal(1, list.Page);
|
||||
|
||||
SearchContainer<PersonResult> listPage2 = _config.Client.GetPersonListAsync(type, 2).Result;
|
||||
|
||||
Assert.IsNotNull(listPage2);
|
||||
Assert.IsTrue(listPage2.Results.Count > 0);
|
||||
Assert.AreEqual(2, listPage2.Page);
|
||||
Assert.NotNull(listPage2);
|
||||
Assert.True(listPage2.Results.Count > 0);
|
||||
Assert.Equal(2, listPage2.Page);
|
||||
|
||||
SearchContainer<PersonResult> list2 = _config.Client.GetPersonListAsync(type).Result;
|
||||
|
||||
Assert.IsNotNull(list2);
|
||||
Assert.IsTrue(list2.Results.Count > 0);
|
||||
Assert.AreEqual(1, list2.Page);
|
||||
Assert.NotNull(list2);
|
||||
Assert.True(list2.Results.Count > 0);
|
||||
Assert.Equal(1, list2.Page);
|
||||
|
||||
// At least one person should differ
|
||||
Assert.IsTrue(list.Results.Any(s => list2.Results.Any(x => x.Name != s.Name)));
|
||||
Assert.True(list.Results.Any(s => list2.Results.Any(x => x.Name != s.Name)));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestGetLatestPerson()
|
||||
{
|
||||
Person item = _config.Client.GetLatestPersonAsync().Result;
|
||||
Assert.IsNotNull(item);
|
||||
Person item = _config.Client.GetLatestPersonAsync().Sync();
|
||||
Assert.NotNull(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Reviews;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLibTests.Helpers;
|
||||
@ -6,36 +6,29 @@ using TMDbLibTests.JsonHelpers;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientReviewTests : TestBase
|
||||
{
|
||||
private TestConfig _config;
|
||||
private readonly TestConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public override void Initiator()
|
||||
public ClientReviewTests()
|
||||
{
|
||||
base.Initiator();
|
||||
|
||||
_config = new TestConfig();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestReviewFullDetails()
|
||||
{
|
||||
Review review = _config.Client.GetReviewAsync(IdHelper.TheDarkKnightRisesReviewId).Result;
|
||||
|
||||
Assert.IsNotNull(review);
|
||||
Assert.NotNull(review);
|
||||
|
||||
Assert.AreEqual(IdHelper.TheDarkKnightRisesReviewId, review.Id);
|
||||
Assert.AreEqual(49026, review.MediaId);
|
||||
Assert.AreEqual("The Dark Knight Rises", review.MediaTitle);
|
||||
Assert.AreEqual("Travis Bell", review.Author);
|
||||
Assert.AreEqual("en", review.Iso_639_1);
|
||||
Assert.AreEqual("https://www.themoviedb.org/review/5010553819c2952d1b000451", review.Url);
|
||||
Assert.AreEqual(MediaType.Movie, review.MediaType);
|
||||
Assert.Equal(IdHelper.TheDarkKnightRisesReviewId, review.Id);
|
||||
Assert.Equal(49026, review.MediaId);
|
||||
Assert.Equal("The Dark Knight Rises", review.MediaTitle);
|
||||
Assert.Equal("Travis Bell", review.Author);
|
||||
Assert.Equal("en", review.Iso_639_1);
|
||||
Assert.Equal("https://www.themoviedb.org/review/5010553819c2952d1b000451", review.Url);
|
||||
Assert.Equal(MediaType.Movie, review.MediaType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.Search;
|
||||
using System.Linq;
|
||||
@ -8,23 +8,16 @@ using TMDbLibTests.JsonHelpers;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientSearchTests : TestBase
|
||||
{
|
||||
private TestConfig _config;
|
||||
private readonly TestConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public override void Initiator()
|
||||
public ClientSearchTests()
|
||||
{
|
||||
base.Initiator();
|
||||
|
||||
_config = new TestConfig();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestSearchMovie()
|
||||
{
|
||||
TestHelpers.SearchPages(i => _config.Client.SearchMovieAsync("007", i).Result);
|
||||
@ -33,178 +26,178 @@ namespace TMDbLibTests
|
||||
// 1962: First James Bond movie, "Dr. No"
|
||||
SearchContainer<SearchMovie> result = _config.Client.SearchMovieAsync("007", year: 1962).Result;
|
||||
|
||||
Assert.IsTrue(result.Results.Any());
|
||||
Assert.True(result.Results.Any());
|
||||
SearchMovie item = result.Results.SingleOrDefault(s => s.Id == 646);
|
||||
|
||||
Assert.IsNotNull(item);
|
||||
Assert.AreEqual(646, item.Id);
|
||||
Assert.AreEqual(false, item.Adult);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(item.BackdropPath), "item.BackdropPath was not a valid image path, was: " + item.BackdropPath);
|
||||
Assert.AreEqual("en", item.OriginalLanguage);
|
||||
Assert.AreEqual("Dr. No", item.OriginalTitle);
|
||||
Assert.AreEqual("In the film that launched the James Bond saga, Agent 007 (Sean Connery) battles mysterious Dr. No, a scientific genius bent on destroying the U.S. space program. As the countdown to disaster begins, Bond must go to Jamaica, where he encounters beautiful Honey Ryder (Ursula Andress), to confront a megalomaniacal villain in his massive island headquarters.", item.Overview);
|
||||
Assert.AreEqual(false, item.Video);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(item.PosterPath), "item.PosterPath was not a valid image path, was: " + item.PosterPath);
|
||||
Assert.AreEqual(new DateTime(1962, 10, 4), item.ReleaseDate);
|
||||
Assert.AreEqual("Dr. No", item.Title);
|
||||
Assert.IsTrue(item.Popularity > 0);
|
||||
Assert.IsTrue(item.VoteAverage > 0);
|
||||
Assert.IsTrue(item.VoteCount > 0);
|
||||
Assert.NotNull(item);
|
||||
Assert.Equal(646, item.Id);
|
||||
Assert.Equal(false, item.Adult);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.BackdropPath), "item.BackdropPath was not a valid image path, was: " + item.BackdropPath);
|
||||
Assert.Equal("en", item.OriginalLanguage);
|
||||
Assert.Equal("Dr. No", item.OriginalTitle);
|
||||
Assert.Equal("In the film that launched the James Bond saga, Agent 007 (Sean Connery) battles mysterious Dr. No, a scientific genius bent on destroying the U.S. space program. As the countdown to disaster begins, Bond must go to Jamaica, where he encounters beautiful Honey Ryder (Ursula Andress), to confront a megalomaniacal villain in his massive island headquarters.", item.Overview);
|
||||
Assert.Equal(false, item.Video);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.PosterPath), "item.PosterPath was not a valid image path, was: " + item.PosterPath);
|
||||
Assert.Equal(new DateTime(1962, 10, 4), item.ReleaseDate);
|
||||
Assert.Equal("Dr. No", item.Title);
|
||||
Assert.True(item.Popularity > 0);
|
||||
Assert.True(item.VoteAverage > 0);
|
||||
Assert.True(item.VoteCount > 0);
|
||||
|
||||
Assert.IsNotNull(item.GenreIds);
|
||||
Assert.IsTrue(item.GenreIds.Contains(12));
|
||||
Assert.IsTrue(item.GenreIds.Contains(28));
|
||||
Assert.IsTrue(item.GenreIds.Contains(53));
|
||||
Assert.NotNull(item.GenreIds);
|
||||
Assert.True(item.GenreIds.Contains(12));
|
||||
Assert.True(item.GenreIds.Contains(28));
|
||||
Assert.True(item.GenreIds.Contains(53));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestSearchCollection()
|
||||
{
|
||||
TestHelpers.SearchPages(i => _config.Client.SearchCollectionAsync("007", i).Result);
|
||||
|
||||
SearchContainer<SearchResultCollection> result = _config.Client.SearchCollectionAsync("James Bond").Result;
|
||||
|
||||
Assert.IsTrue(result.Results.Any());
|
||||
Assert.True(result.Results.Any());
|
||||
SearchResultCollection item = result.Results.SingleOrDefault(s => s.Id == 645);
|
||||
|
||||
Assert.IsNotNull(item);
|
||||
Assert.AreEqual(645, item.Id);
|
||||
Assert.AreEqual("James Bond Collection", item.Name);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(item.BackdropPath), "item.BackdropPath was not a valid image path, was: " + item.BackdropPath);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(item.PosterPath), "item.PosterPath was not a valid image path, was: " + item.PosterPath);
|
||||
Assert.NotNull(item);
|
||||
Assert.Equal(645, item.Id);
|
||||
Assert.Equal("James Bond Collection", item.Name);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.BackdropPath), "item.BackdropPath was not a valid image path, was: " + item.BackdropPath);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.PosterPath), "item.PosterPath was not a valid image path, was: " + item.PosterPath);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestSearchPerson()
|
||||
{
|
||||
TestHelpers.SearchPages(i => _config.Client.SearchPersonAsync("Willis", i).Result);
|
||||
|
||||
SearchContainer<SearchPerson> result = _config.Client.SearchPersonAsync("Willis").Result;
|
||||
|
||||
Assert.IsTrue(result.Results.Any());
|
||||
Assert.True(result.Results.Any());
|
||||
SearchPerson item = result.Results.SingleOrDefault(s => s.Id == 62);
|
||||
|
||||
Assert.IsNotNull(item);
|
||||
Assert.AreEqual(62, item.Id);
|
||||
Assert.AreEqual("Bruce Willis", item.Name);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(item.ProfilePath), "item.ProfilePath was not a valid image path, was: " + item.ProfilePath);
|
||||
Assert.AreEqual(false, item.Adult);
|
||||
Assert.IsTrue(item.Popularity > 0);
|
||||
Assert.NotNull(item);
|
||||
Assert.Equal(62, item.Id);
|
||||
Assert.Equal("Bruce Willis", item.Name);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.ProfilePath), "item.ProfilePath was not a valid image path, was: " + item.ProfilePath);
|
||||
Assert.Equal(false, item.Adult);
|
||||
Assert.True(item.Popularity > 0);
|
||||
|
||||
Assert.IsNotNull(item.KnownFor);
|
||||
Assert.IsTrue(item.KnownFor.Any(s => s.Id == 680));
|
||||
Assert.NotNull(item.KnownFor);
|
||||
Assert.True(item.KnownFor.Any(s => s.Id == 680));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestSearchList()
|
||||
{
|
||||
TestHelpers.SearchPages(i => _config.Client.SearchListAsync("to watch", i).Result);
|
||||
|
||||
SearchContainer<SearchList> result = _config.Client.SearchListAsync("to watch").Result;
|
||||
|
||||
Assert.IsTrue(result.Results.Any());
|
||||
Assert.True(result.Results.Any());
|
||||
SearchList item = result.Results.SingleOrDefault(s => s.Id == "54a5c0ceaed56c28c300013a");
|
||||
|
||||
Assert.IsNotNull(item);
|
||||
Assert.AreEqual("to watch", item.Description);
|
||||
Assert.AreEqual("54a5c0ceaed56c28c300013a", item.Id);
|
||||
Assert.AreEqual("en", item.Iso_639_1);
|
||||
Assert.AreEqual("movie", item.ListType);
|
||||
Assert.AreEqual("Movies", item.Name);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(item.PosterPath), "item.PosterPath was not a valid image path, was: " + item.PosterPath);
|
||||
Assert.IsTrue(item.FavoriteCount > 0);
|
||||
Assert.IsTrue(item.ItemCount > 0);
|
||||
Assert.NotNull(item);
|
||||
Assert.Equal("to watch", item.Description);
|
||||
Assert.Equal("54a5c0ceaed56c28c300013a", item.Id);
|
||||
Assert.Equal("en", item.Iso_639_1);
|
||||
Assert.Equal("movie", item.ListType);
|
||||
Assert.Equal("Movies", item.Name);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.PosterPath), "item.PosterPath was not a valid image path, was: " + item.PosterPath);
|
||||
Assert.True(item.FavoriteCount > 0);
|
||||
Assert.True(item.ItemCount > 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestSearchCompany()
|
||||
{
|
||||
TestHelpers.SearchPages(i => _config.Client.SearchCompanyAsync("20th", i).Result);
|
||||
|
||||
SearchContainer<SearchCompany> result = _config.Client.SearchCompanyAsync("20th").Result;
|
||||
|
||||
Assert.IsTrue(result.Results.Any());
|
||||
Assert.True(result.Results.Any());
|
||||
SearchCompany item = result.Results.SingleOrDefault(s => s.Id == 25);
|
||||
|
||||
Assert.IsNotNull(item);
|
||||
Assert.AreEqual(25, item.Id);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(item.LogoPath), "item.LogoPath was not a valid image path, was: " + item.LogoPath);
|
||||
Assert.AreEqual("20th Century Fox", item.Name);
|
||||
Assert.NotNull(item);
|
||||
Assert.Equal(25, item.Id);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.LogoPath), "item.LogoPath was not a valid image path, was: " + item.LogoPath);
|
||||
Assert.Equal("20th Century Fox", item.Name);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestSearchKeyword()
|
||||
{
|
||||
TestHelpers.SearchPages(i => _config.Client.SearchKeywordAsync("plot", i).Result);
|
||||
|
||||
SearchContainer<SearchKeyword> result = _config.Client.SearchKeywordAsync("plot").Result;
|
||||
|
||||
Assert.IsTrue(result.Results.Any());
|
||||
Assert.True(result.Results.Any());
|
||||
SearchKeyword item = result.Results.SingleOrDefault(s => s.Id == 11121);
|
||||
|
||||
Assert.IsNotNull(item);
|
||||
Assert.AreEqual(11121, item.Id);
|
||||
Assert.AreEqual("plot", item.Name);
|
||||
Assert.NotNull(item);
|
||||
Assert.Equal(11121, item.Id);
|
||||
Assert.Equal("plot", item.Name);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestSearchTvShow()
|
||||
{
|
||||
TestHelpers.SearchPages(i => _config.Client.SearchTvShowAsync("Breaking Bad", i).Result);
|
||||
|
||||
SearchContainer<SearchTv> result = _config.Client.SearchTvShowAsync("Breaking Bad").Result;
|
||||
|
||||
Assert.IsTrue(result.Results.Any());
|
||||
Assert.True(result.Results.Any());
|
||||
SearchTv item = result.Results.SingleOrDefault(s => s.Id == 1396);
|
||||
|
||||
Assert.IsNotNull(item);
|
||||
Assert.AreEqual(1396, item.Id);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(item.BackdropPath), "item.BackdropPath was not a valid image path, was: " + item.BackdropPath);
|
||||
Assert.AreEqual(new DateTime(2008, 1, 19), item.FirstAirDate);
|
||||
Assert.AreEqual("Breaking Bad", item.Name);
|
||||
Assert.AreEqual("Breaking Bad", item.OriginalName);
|
||||
Assert.AreEqual("en", item.OriginalLanguage);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(item.PosterPath), "item.PosterPath was not a valid image path, was: " + item.PosterPath);
|
||||
Assert.AreEqual("Breaking Bad is an American crime drama television series created and produced by Vince Gilligan. Set and produced in Albuquerque, New Mexico, Breaking Bad is the story of Walter White, a struggling high school chemistry teacher who is diagnosed with inoperable lung cancer at the beginning of the series. He turns to a life of crime, producing and selling methamphetamine, in order to secure his family's financial future before he dies, teaming with his former student, Jesse Pinkman. Heavily serialized, the series is known for positioning its characters in seemingly inextricable corners and has been labeled a contemporary western by its creator.", item.Overview);
|
||||
Assert.IsTrue(item.Popularity > 0);
|
||||
Assert.IsTrue(item.VoteAverage > 0);
|
||||
Assert.IsTrue(item.VoteCount > 0);
|
||||
Assert.NotNull(item);
|
||||
Assert.Equal(1396, item.Id);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.BackdropPath), "item.BackdropPath was not a valid image path, was: " + item.BackdropPath);
|
||||
Assert.Equal(new DateTime(2008, 1, 19), item.FirstAirDate);
|
||||
Assert.Equal("Breaking Bad", item.Name);
|
||||
Assert.Equal("Breaking Bad", item.OriginalName);
|
||||
Assert.Equal("en", item.OriginalLanguage);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.PosterPath), "item.PosterPath was not a valid image path, was: " + item.PosterPath);
|
||||
Assert.Equal("Breaking Bad is an American crime drama television series created and produced by Vince Gilligan. Set and produced in Albuquerque, New Mexico, Breaking Bad is the story of Walter White, a struggling high school chemistry teacher who is diagnosed with inoperable lung cancer at the beginning of the series. He turns to a life of crime, producing and selling methamphetamine, in order to secure his family's financial future before he dies, teaming with his former student, Jesse Pinkman. Heavily serialized, the series is known for positioning its characters in seemingly inextricable corners and has been labeled a contemporary western by its creator.", item.Overview);
|
||||
Assert.True(item.Popularity > 0);
|
||||
Assert.True(item.VoteAverage > 0);
|
||||
Assert.True(item.VoteCount > 0);
|
||||
|
||||
Assert.IsNotNull(item.GenreIds);
|
||||
Assert.AreEqual(1, item.GenreIds.Count);
|
||||
Assert.AreEqual(18, item.GenreIds[0]);
|
||||
Assert.NotNull(item.GenreIds);
|
||||
Assert.Equal(1, item.GenreIds.Count);
|
||||
Assert.Equal(18, item.GenreIds[0]);
|
||||
|
||||
Assert.IsNotNull(item.OriginCountry);
|
||||
Assert.AreEqual(1, item.OriginCountry.Count);
|
||||
Assert.AreEqual("US", item.OriginCountry[0]);
|
||||
Assert.NotNull(item.OriginCountry);
|
||||
Assert.Equal(1, item.OriginCountry.Count);
|
||||
Assert.Equal("US", item.OriginCountry[0]);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestSearchMulti()
|
||||
{
|
||||
TestHelpers.SearchPages(i => _config.Client.SearchMultiAsync("Arrow", i).Result);
|
||||
|
||||
SearchContainer<SearchMulti> result = _config.Client.SearchMultiAsync("Arrow").Result;
|
||||
|
||||
Assert.IsTrue(result.Results.Any());
|
||||
Assert.True(result.Results.Any());
|
||||
SearchMulti item = result.Results.SingleOrDefault(s => s.Id == 1412);
|
||||
|
||||
Assert.IsNotNull(item);
|
||||
Assert.AreEqual(1412, item.Id);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(item.BackdropPath), "item.BackdropPath was not a valid image path, was: " + item.BackdropPath);
|
||||
Assert.AreEqual(new DateTime(2012, 10, 10), item.FirstAirDate);
|
||||
Assert.AreEqual(MediaType.TVShow, item.Type);
|
||||
Assert.AreEqual("Arrow", item.Name);
|
||||
Assert.AreEqual("Arrow", item.OriginalName);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(item.PosterPath), "item.PosterPath was not a valid image path, was: " + item.PosterPath);
|
||||
Assert.IsTrue(item.Popularity > 0);
|
||||
Assert.IsTrue(item.VoteAverage > 0);
|
||||
Assert.IsTrue(item.VoteCount > 0);
|
||||
Assert.NotNull(item);
|
||||
Assert.Equal(1412, item.Id);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.BackdropPath), "item.BackdropPath was not a valid image path, was: " + item.BackdropPath);
|
||||
Assert.Equal(new DateTime(2012, 10, 10), item.FirstAirDate);
|
||||
Assert.Equal(MediaType.TVShow, item.Type);
|
||||
Assert.Equal("Arrow", item.Name);
|
||||
Assert.Equal("Arrow", item.OriginalName);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.PosterPath), "item.PosterPath was not a valid image path, was: " + item.PosterPath);
|
||||
Assert.True(item.Popularity > 0);
|
||||
Assert.True(item.VoteAverage > 0);
|
||||
Assert.True(item.VoteCount > 0);
|
||||
|
||||
Assert.IsNotNull(item.OriginCountry);
|
||||
Assert.AreEqual(2, item.OriginCountry.Count);
|
||||
Assert.IsTrue(item.OriginCountry.Contains("US"));
|
||||
Assert.IsTrue(item.OriginCountry.Contains("CA"));
|
||||
Assert.NotNull(item.OriginCountry);
|
||||
Assert.Equal(2, item.OriginCountry.Count);
|
||||
Assert.True(item.OriginCountry.Contains("US"));
|
||||
Assert.True(item.OriginCountry.Contains("CA"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
using TMDbLib.Client;
|
||||
using TMDbLib.Objects.Exceptions;
|
||||
using TMDbLib.Objects.General;
|
||||
@ -10,55 +10,44 @@ using TMDbLibTests.JsonHelpers;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientTests : TestBase
|
||||
{
|
||||
private TestConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public override void Initiator()
|
||||
public ClientTests()
|
||||
{
|
||||
base.Initiator();
|
||||
|
||||
_config = new TestConfig();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void GetConfigTest()
|
||||
{
|
||||
Assert.IsFalse(_config.Client.HasConfig);
|
||||
Assert.False(_config.Client.HasConfig);
|
||||
_config.Client.GetConfig();
|
||||
Assert.IsTrue(_config.Client.HasConfig);
|
||||
Assert.True(_config.Client.HasConfig);
|
||||
|
||||
Assert.IsNotNull(_config.Client.Config);
|
||||
Assert.NotNull(_config.Client.Config);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void GetConfigSslTest()
|
||||
{
|
||||
_config = new TestConfig(true);
|
||||
|
||||
Assert.IsFalse(_config.Client.HasConfig);
|
||||
Assert.False(_config.Client.HasConfig);
|
||||
_config.Client.GetConfig();
|
||||
Assert.IsTrue(_config.Client.HasConfig);
|
||||
Assert.True(_config.Client.HasConfig);
|
||||
|
||||
Assert.IsNotNull(_config.Client.Config);
|
||||
Assert.NotNull(_config.Client.Config);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(InvalidOperationException), AllowDerivedTypes = false)]
|
||||
[Fact]
|
||||
public void GetConfigFailTest()
|
||||
{
|
||||
TMDbConfig config = _config.Client.Config;
|
||||
|
||||
// Should always throw exception
|
||||
Assert.Fail();
|
||||
Assert.Throws<InvalidOperationException>(() => _config.Client.Config);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void SetConfigTest()
|
||||
{
|
||||
TMDbConfig config = new TMDbConfig();
|
||||
@ -67,14 +56,14 @@ namespace TMDbLibTests
|
||||
config.Images = new ConfigImageTypes();
|
||||
config.Images.BaseUrl = " ..";
|
||||
|
||||
Assert.IsFalse(_config.Client.HasConfig);
|
||||
Assert.False(_config.Client.HasConfig);
|
||||
_config.Client.SetConfig(config);
|
||||
Assert.IsTrue(_config.Client.HasConfig);
|
||||
Assert.True(_config.Client.HasConfig);
|
||||
|
||||
Assert.AreSame(config, _config.Client.Config);
|
||||
Assert.Same(config, _config.Client.Config);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void ClientConstructorUrlTest()
|
||||
{
|
||||
TMDbClient clientA = new TMDbClient(TestConfig.APIKey, false, "http://api.themoviedb.org");
|
||||
@ -90,19 +79,15 @@ namespace TMDbLibTests
|
||||
clientD.GetConfig();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
[Fact]
|
||||
public void ClientSetBadMaxRetryValue()
|
||||
{
|
||||
TMDbClient client = new TMDbClient(TestConfig.APIKey);
|
||||
|
||||
client.MaxRetryCount = -1;
|
||||
|
||||
Assert.Fail();
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => client.MaxRetryCount = -1);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(RequestLimitExceededException))]
|
||||
[Fact]
|
||||
public void ClientRateLimitTest()
|
||||
{
|
||||
const int id = IdHelper.AGoodDayToDieHard;
|
||||
@ -110,28 +95,21 @@ namespace TMDbLibTests
|
||||
TMDbClient client = new TMDbClient(TestConfig.APIKey);
|
||||
client.MaxRetryCount = 0;
|
||||
|
||||
try
|
||||
Assert.Throws<RequestLimitExceededException>(() =>
|
||||
{
|
||||
Parallel.For(0, 100, i =>
|
||||
try
|
||||
{
|
||||
try
|
||||
Parallel.For(0, 100, i =>
|
||||
{
|
||||
client.GetMovieAsync(id).Wait();
|
||||
}
|
||||
catch (AggregateException ex)
|
||||
{
|
||||
// Unpack the InnerException
|
||||
throw ex.InnerException;
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (AggregateException ex)
|
||||
{
|
||||
// Unpack the InnerException
|
||||
throw ex.InnerException;
|
||||
}
|
||||
|
||||
Assert.Fail();
|
||||
client.GetMovieAsync(id).Sync();
|
||||
});
|
||||
}
|
||||
catch (AggregateException ex)
|
||||
{
|
||||
// Unpack the InnerException
|
||||
throw ex.InnerException;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,38 +1,32 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Timezones;
|
||||
using TMDbLibTests.Helpers;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientTimezonesTests : TestBase
|
||||
{
|
||||
private TestConfig _config;
|
||||
private readonly TestConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public override void Initiator()
|
||||
public ClientTimezonesTests()
|
||||
{
|
||||
base.Initiator();
|
||||
|
||||
_config = new TestConfig();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTimezonesList()
|
||||
{
|
||||
Timezones result = _config.Client.GetTimezonesAsync().Result;
|
||||
Timezones result = _config.Client.GetTimezonesAsync().Sync();
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsTrue(result.List.Count > 200);
|
||||
Assert.NotNull(result);
|
||||
Assert.True(result.List.Count > 200);
|
||||
|
||||
List<string> item = result.List["DK"];
|
||||
Assert.IsNotNull(item);
|
||||
Assert.AreEqual(1, item.Count);
|
||||
Assert.AreEqual("Europe/Copenhagen", item[0]);
|
||||
Assert.NotNull(item);
|
||||
Assert.Equal(1, item.Count);
|
||||
Assert.Equal("Europe/Copenhagen", item[0]);
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
using TMDbLib.Objects.Changes;
|
||||
using TMDbLib.Objects.General;
|
||||
@ -15,38 +15,26 @@ using Credits = TMDbLib.Objects.TvShows.Credits;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientTvEpisodeTests : TestBase
|
||||
{
|
||||
private static Dictionary<TvEpisodeMethods, Func<TvEpisode, object>> _methods;
|
||||
private TestConfig _config;
|
||||
private readonly TestConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public override void Initiator()
|
||||
public ClientTvEpisodeTests()
|
||||
{
|
||||
base.Initiator();
|
||||
|
||||
_config = new TestConfig();
|
||||
|
||||
_methods = new Dictionary<TvEpisodeMethods, Func<TvEpisode, object>>
|
||||
{
|
||||
[TvEpisodeMethods.Credits] = tvEpisode => tvEpisode.Credits,
|
||||
[TvEpisodeMethods.Images] = tvEpisode => tvEpisode.Images,
|
||||
[TvEpisodeMethods.ExternalIds] = tvEpisode => tvEpisode.ExternalIds,
|
||||
[TvEpisodeMethods.Videos] = tvEpisode => tvEpisode.Videos,
|
||||
[TvEpisodeMethods.AccountStates] = tvEpisode => tvEpisode.AccountStates
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on test class initialization
|
||||
/// </summary>
|
||||
[ClassInitialize]
|
||||
public static void InitialInitiator(TestContext context)
|
||||
{
|
||||
_methods = new Dictionary<TvEpisodeMethods, Func<TvEpisode, object>>();
|
||||
_methods[TvEpisodeMethods.Credits] = tvEpisode => tvEpisode.Credits;
|
||||
_methods[TvEpisodeMethods.Images] = tvEpisode => tvEpisode.Images;
|
||||
_methods[TvEpisodeMethods.ExternalIds] = tvEpisode => tvEpisode.ExternalIds;
|
||||
_methods[TvEpisodeMethods.Videos] = tvEpisode => tvEpisode.Videos;
|
||||
_methods[TvEpisodeMethods.AccountStates] = tvEpisode => tvEpisode.AccountStates;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvEpisodeExtrasNone()
|
||||
{
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
@ -59,11 +47,11 @@ namespace TMDbLibTests
|
||||
// Test all extras, ensure none of them are populated
|
||||
foreach (Func<TvEpisode, object> selector in _methods.Values)
|
||||
{
|
||||
Assert.IsNull(selector(tvEpisode));
|
||||
Assert.Null(selector(tvEpisode));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvEpisodeExtrasAccountState()
|
||||
{
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
@ -75,7 +63,7 @@ namespace TMDbLibTests
|
||||
TvEpisode episode = _config.Client.GetTvEpisodeAsync(IdHelper.BigBangTheory, 1, 1, TvEpisodeMethods.AccountStates).Result;
|
||||
if (episode.AccountStates == null || !episode.AccountStates.Rating.HasValue)
|
||||
{
|
||||
_config.Client.TvEpisodeSetRatingAsync(IdHelper.BigBangTheory, 1, 1, 5).Wait();
|
||||
_config.Client.TvEpisodeSetRatingAsync(IdHelper.BigBangTheory, 1, 1, 5).Sync();
|
||||
|
||||
// Allow TMDb to update cache
|
||||
Thread.Sleep(2000);
|
||||
@ -83,91 +71,91 @@ namespace TMDbLibTests
|
||||
episode = _config.Client.GetTvEpisodeAsync(IdHelper.BigBangTheory, 1, 1, TvEpisodeMethods.AccountStates).Result;
|
||||
}
|
||||
|
||||
Assert.IsNotNull(episode.AccountStates);
|
||||
Assert.IsTrue(episode.AccountStates.Rating.HasValue);
|
||||
Assert.IsTrue(Math.Abs(episode.AccountStates.Rating.Value - 5) < double.Epsilon);
|
||||
Assert.NotNull(episode.AccountStates);
|
||||
Assert.True(episode.AccountStates.Rating.HasValue);
|
||||
Assert.True(Math.Abs(episode.AccountStates.Rating.Value - 5) < double.Epsilon);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvEpisodeExtrasAll()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Account states will only show up if we've done something
|
||||
_config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 5).Wait();
|
||||
_config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 5).Sync();
|
||||
|
||||
TvEpisodeMethods combinedEnum = _methods.Keys.Aggregate((methods, tvEpisodeMethods) => methods | tvEpisodeMethods);
|
||||
TvEpisode tvEpisode = _config.Client.GetTvEpisodeAsync(IdHelper.BreakingBad, 1, 1, combinedEnum).Result;
|
||||
|
||||
TestBreakingBadSeasonOneEpisodeOneBaseProperties(tvEpisode);
|
||||
|
||||
Assert.IsNotNull(tvEpisode.Images);
|
||||
Assert.IsNotNull(tvEpisode.Images.Stills);
|
||||
Assert.IsTrue(tvEpisode.Images.Stills.Count > 0);
|
||||
Assert.NotNull(tvEpisode.Images);
|
||||
Assert.NotNull(tvEpisode.Images.Stills);
|
||||
Assert.True(tvEpisode.Images.Stills.Count > 0);
|
||||
|
||||
TestMethodsHelper.TestAllNotNull(_methods, tvEpisode);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvEpisodeExtrasExclusive()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetTvEpisodeAsync(id, 1, 1, extras).Result, IdHelper.BreakingBad);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvEpisodeSeparateExtrasCredits()
|
||||
{
|
||||
Credits credits = _config.Client.GetTvEpisodeCreditsAsync(IdHelper.BreakingBad, 1, 1).Result;
|
||||
Assert.IsNotNull(credits);
|
||||
Assert.IsNotNull(credits.Cast);
|
||||
Assert.AreEqual("Walter White", credits.Cast[0].Character);
|
||||
Assert.AreEqual("52542282760ee313280017f9", credits.Cast[0].CreditId);
|
||||
Assert.AreEqual(17419, credits.Cast[0].Id);
|
||||
Assert.AreEqual("Bryan Cranston", credits.Cast[0].Name);
|
||||
Assert.IsNotNull(credits.Cast[0].ProfilePath);
|
||||
Assert.AreEqual(0, credits.Cast[0].Order);
|
||||
Assert.NotNull(credits);
|
||||
Assert.NotNull(credits.Cast);
|
||||
Assert.Equal("Walter White", credits.Cast[0].Character);
|
||||
Assert.Equal("52542282760ee313280017f9", credits.Cast[0].CreditId);
|
||||
Assert.Equal(17419, credits.Cast[0].Id);
|
||||
Assert.Equal("Bryan Cranston", credits.Cast[0].Name);
|
||||
Assert.NotNull(credits.Cast[0].ProfilePath);
|
||||
Assert.Equal(0, credits.Cast[0].Order);
|
||||
|
||||
Crew crewPersonId = credits.Crew.FirstOrDefault(s => s.Id == 1280071);
|
||||
Assert.IsNotNull(crewPersonId);
|
||||
Assert.NotNull(crewPersonId);
|
||||
|
||||
Assert.AreEqual(1280071, crewPersonId.Id);
|
||||
Assert.AreEqual("Editing", crewPersonId.Department);
|
||||
Assert.AreEqual("Lynne Willingham", crewPersonId.Name);
|
||||
Assert.AreEqual("Editor", crewPersonId.Job);
|
||||
Assert.IsNull(crewPersonId.ProfilePath);
|
||||
Assert.Equal(1280071, crewPersonId.Id);
|
||||
Assert.Equal("Editing", crewPersonId.Department);
|
||||
Assert.Equal("Lynne Willingham", crewPersonId.Name);
|
||||
Assert.Equal("Editor", crewPersonId.Job);
|
||||
Assert.Null(crewPersonId.ProfilePath);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvEpisodeSeparateExtrasExternalIds()
|
||||
{
|
||||
ExternalIds externalIds = _config.Client.GetTvEpisodeExternalIdsAsync(IdHelper.BreakingBad, 1, 1).Result;
|
||||
Assert.IsNotNull(externalIds);
|
||||
Assert.IsTrue(string.IsNullOrEmpty(externalIds.FreebaseId));
|
||||
Assert.AreEqual(62085, externalIds.Id);
|
||||
Assert.AreEqual("/m/03mb620", externalIds.FreebaseMid);
|
||||
Assert.AreEqual("tt0959621", externalIds.ImdbId);
|
||||
Assert.AreEqual("637041", externalIds.TvrageId);
|
||||
Assert.AreEqual("349232", externalIds.TvdbId);
|
||||
Assert.NotNull(externalIds);
|
||||
Assert.True(string.IsNullOrEmpty(externalIds.FreebaseId));
|
||||
Assert.Equal(62085, externalIds.Id);
|
||||
Assert.Equal("/m/03mb620", externalIds.FreebaseMid);
|
||||
Assert.Equal("tt0959621", externalIds.ImdbId);
|
||||
Assert.Equal("637041", externalIds.TvrageId);
|
||||
Assert.Equal("349232", externalIds.TvdbId);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvEpisodeSeparateExtrasImages()
|
||||
{
|
||||
StillImages images = _config.Client.GetTvEpisodeImagesAsync(IdHelper.BreakingBad, 1, 1).Result;
|
||||
Assert.IsNotNull(images);
|
||||
Assert.IsNotNull(images.Stills);
|
||||
Assert.NotNull(images);
|
||||
Assert.NotNull(images.Stills);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvEpisodeSeparateExtrasVideos()
|
||||
{
|
||||
ResultContainer<Video> images = _config.Client.GetTvEpisodeVideosAsync(IdHelper.BreakingBad, 1, 1).Result;
|
||||
Assert.IsNotNull(images);
|
||||
Assert.IsNotNull(images.Results);
|
||||
Assert.NotNull(images);
|
||||
Assert.NotNull(images.Results);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvEpisodeAccountStateRatingSet()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
@ -176,7 +164,7 @@ namespace TMDbLibTests
|
||||
// Remove the rating
|
||||
if (accountState.Rating.HasValue)
|
||||
{
|
||||
Assert.IsTrue(_config.Client.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 1).Result);
|
||||
Assert.True(_config.Client.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 1).Result);
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
@ -185,96 +173,96 @@ namespace TMDbLibTests
|
||||
// Test that the episode is NOT rated
|
||||
accountState = _config.Client.GetTvEpisodeAccountStateAsync(IdHelper.BreakingBad, 1, 1).Result;
|
||||
|
||||
Assert.AreEqual(IdHelper.BreakingBadSeason1Episode1Id, accountState.Id);
|
||||
Assert.IsFalse(accountState.Rating.HasValue);
|
||||
Assert.Equal(IdHelper.BreakingBadSeason1Episode1Id, accountState.Id);
|
||||
Assert.False(accountState.Rating.HasValue);
|
||||
|
||||
// Rate the episode
|
||||
Assert.IsTrue(_config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 5).Result);
|
||||
Assert.True(_config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 5).Result);
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
// Test that the episode IS rated
|
||||
accountState = _config.Client.GetTvEpisodeAccountStateAsync(IdHelper.BreakingBad, 1, 1).Result;
|
||||
Assert.AreEqual(IdHelper.BreakingBadSeason1Episode1Id, accountState.Id);
|
||||
Assert.IsTrue(accountState.Rating.HasValue);
|
||||
Assert.Equal(IdHelper.BreakingBadSeason1Episode1Id, accountState.Id);
|
||||
Assert.True(accountState.Rating.HasValue);
|
||||
|
||||
// Remove the rating
|
||||
Assert.IsTrue(_config.Client.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 1).Result);
|
||||
Assert.True(_config.Client.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 1).Result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvEpisodeRateBad()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
|
||||
Assert.IsFalse(_config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, -1).Result);
|
||||
Assert.IsFalse(_config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 0).Result);
|
||||
Assert.IsFalse(_config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 10.5).Result);
|
||||
Assert.False(_config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, -1).Result);
|
||||
Assert.False(_config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 0).Result);
|
||||
Assert.False(_config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 10.5).Result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvEpisodeGetChanges()
|
||||
{
|
||||
ChangesContainer changes = _config.Client.GetTvEpisodeChangesAsync(IdHelper.BreakingBadSeason1Episode1Id).Result;
|
||||
|
||||
Assert.IsNotNull(changes);
|
||||
Assert.IsNotNull(changes.Changes);
|
||||
Assert.NotNull(changes);
|
||||
Assert.NotNull(changes.Changes);
|
||||
}
|
||||
|
||||
private void TestBreakingBadSeasonOneEpisodeOneBaseProperties(TvEpisode tvEpisode)
|
||||
{
|
||||
Assert.AreEqual(62085, tvEpisode.Id);
|
||||
Assert.IsTrue(tvEpisode.AirDate.HasValue);
|
||||
Assert.AreEqual(new DateTime(2008, 1, 19), tvEpisode.AirDate.Value.Date);
|
||||
Assert.AreEqual(1, tvEpisode.EpisodeNumber);
|
||||
Assert.AreEqual("Pilot", tvEpisode.Name);
|
||||
Assert.IsNotNull(tvEpisode.Overview);
|
||||
Assert.IsNull(tvEpisode.ProductionCode);
|
||||
Assert.AreEqual(1, tvEpisode.SeasonNumber);
|
||||
Assert.IsNotNull(tvEpisode.StillPath);
|
||||
Assert.Equal(62085, tvEpisode.Id);
|
||||
Assert.True(tvEpisode.AirDate.HasValue);
|
||||
Assert.Equal(new DateTime(2008, 1, 19), tvEpisode.AirDate.Value.Date);
|
||||
Assert.Equal(1, tvEpisode.EpisodeNumber);
|
||||
Assert.Equal("Pilot", tvEpisode.Name);
|
||||
Assert.NotNull(tvEpisode.Overview);
|
||||
Assert.Null(tvEpisode.ProductionCode);
|
||||
Assert.Equal(1, tvEpisode.SeasonNumber);
|
||||
Assert.NotNull(tvEpisode.StillPath);
|
||||
|
||||
Assert.IsNotNull(tvEpisode.Crew);
|
||||
Assert.NotNull(tvEpisode.Crew);
|
||||
Crew crew = tvEpisode.Crew.SingleOrDefault(s => s.CreditId == "52542275760ee313280006ce");
|
||||
Assert.IsNotNull(crew);
|
||||
Assert.NotNull(crew);
|
||||
|
||||
Assert.AreEqual(66633, crew.Id);
|
||||
Assert.AreEqual("52542275760ee313280006ce", crew.CreditId);
|
||||
Assert.AreEqual("Vince Gilligan", crew.Name);
|
||||
Assert.AreEqual("Writing", crew.Department);
|
||||
Assert.AreEqual("Writer", crew.Job);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(crew.ProfilePath), "crew.ProfilePath was not a valid image path, was: " + crew.ProfilePath);
|
||||
Assert.Equal(66633, crew.Id);
|
||||
Assert.Equal("52542275760ee313280006ce", crew.CreditId);
|
||||
Assert.Equal("Vince Gilligan", crew.Name);
|
||||
Assert.Equal("Writing", crew.Department);
|
||||
Assert.Equal("Writer", crew.Job);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(crew.ProfilePath), "crew.ProfilePath was not a valid image path, was: " + crew.ProfilePath);
|
||||
|
||||
Assert.IsNotNull(tvEpisode.GuestStars);
|
||||
Assert.NotNull(tvEpisode.GuestStars);
|
||||
Cast star = tvEpisode.GuestStars.SingleOrDefault(s => s.CreditId == "52542273760ee3132800068e");
|
||||
Assert.IsNotNull(star);
|
||||
Assert.NotNull(star);
|
||||
|
||||
Assert.AreEqual(92495, star.Id);
|
||||
Assert.AreEqual("John Koyama", star.Name);
|
||||
Assert.AreEqual("52542273760ee3132800068e", star.CreditId);
|
||||
Assert.AreEqual("Emilio Koyama", star.Character);
|
||||
Assert.AreEqual(1, star.Order);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(star.ProfilePath), "star.ProfilePath was not a valid image path, was: " + star.ProfilePath);
|
||||
Assert.Equal(92495, star.Id);
|
||||
Assert.Equal("John Koyama", star.Name);
|
||||
Assert.Equal("52542273760ee3132800068e", star.CreditId);
|
||||
Assert.Equal("Emilio Koyama", star.Character);
|
||||
Assert.Equal(1, star.Order);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(star.ProfilePath), "star.ProfilePath was not a valid image path, was: " + star.ProfilePath);
|
||||
|
||||
}
|
||||
|
||||
//[TestMethod]
|
||||
//[Fact]
|
||||
//public void TestMoviesLanguage()
|
||||
//{
|
||||
// Movie movie = _config.Client.GetMovieAsync(AGoodDayToDieHard);
|
||||
// Movie movieItalian = _config.Client.GetMovieAsync(AGoodDayToDieHard, "it");
|
||||
|
||||
// Assert.IsNotNull(movie);
|
||||
// Assert.IsNotNull(movieItalian);
|
||||
// Assert.NotNull(movie);
|
||||
// Assert.NotNull(movieItalian);
|
||||
|
||||
// Assert.AreEqual("A Good Day to Die Hard", movie.Title);
|
||||
// Assert.AreNotEqual(movie.Title, movieItalian.Title);
|
||||
// Assert.Equal("A Good Day to Die Hard", movie.Title);
|
||||
// Assert.NotEqual(movie.Title, movieItalian.Title);
|
||||
|
||||
// // Test all extras, ensure none of them exist
|
||||
// foreach (Func<Movie, object> selector in _methods.Values)
|
||||
// {
|
||||
// Assert.IsNull(selector(movie));
|
||||
// Assert.IsNull(selector(movieItalian));
|
||||
// Assert.Null(selector(movie));
|
||||
// Assert.Null(selector(movieItalian));
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
using TMDbLib.Objects.Changes;
|
||||
using TMDbLib.Objects.General;
|
||||
@ -14,39 +14,27 @@ using Credits = TMDbLib.Objects.TvShows.Credits;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientTvSeasonTests : TestBase
|
||||
{
|
||||
private static Dictionary<TvSeasonMethods, Func<TvSeason, object>> _methods;
|
||||
private TestConfig _config;
|
||||
private readonly TestConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public override void Initiator()
|
||||
public ClientTvSeasonTests()
|
||||
{
|
||||
base.Initiator();
|
||||
|
||||
_config = new TestConfig();
|
||||
|
||||
_methods = new Dictionary<TvSeasonMethods, Func<TvSeason, object>>
|
||||
{
|
||||
[TvSeasonMethods.Credits] = tvSeason => tvSeason.Credits,
|
||||
[TvSeasonMethods.Images] = tvSeason => tvSeason.Images,
|
||||
[TvSeasonMethods.ExternalIds] = tvSeason => tvSeason.ExternalIds,
|
||||
[TvSeasonMethods.Videos] = tvSeason => tvSeason.Videos,
|
||||
[TvSeasonMethods.Videos] = tvSeason => tvSeason.Videos,
|
||||
[TvSeasonMethods.AccountStates] = tvSeason => tvSeason.AccountStates
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on test class initialization
|
||||
/// </summary>
|
||||
[ClassInitialize]
|
||||
public static void InitialInitiator(TestContext context)
|
||||
{
|
||||
_methods = new Dictionary<TvSeasonMethods, Func<TvSeason, object>>();
|
||||
_methods[TvSeasonMethods.Credits] = tvSeason => tvSeason.Credits;
|
||||
_methods[TvSeasonMethods.Images] = tvSeason => tvSeason.Images;
|
||||
_methods[TvSeasonMethods.ExternalIds] = tvSeason => tvSeason.ExternalIds;
|
||||
_methods[TvSeasonMethods.Videos] = tvSeason => tvSeason.Videos;
|
||||
_methods[TvSeasonMethods.Videos] = tvSeason => tvSeason.Videos;
|
||||
_methods[TvSeasonMethods.AccountStates] = tvSeason => tvSeason.AccountStates;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvSeasonExtrasNone()
|
||||
{
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
@ -59,11 +47,11 @@ namespace TMDbLibTests
|
||||
// Test all extras, ensure none of them are populated
|
||||
foreach (Func<TvSeason, object> selector in _methods.Values)
|
||||
{
|
||||
Assert.IsNull(selector(tvSeason));
|
||||
Assert.Null(selector(tvSeason));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvSeasonExtrasAccountState()
|
||||
{
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
@ -75,7 +63,7 @@ namespace TMDbLibTests
|
||||
TvSeason season = _config.Client.GetTvSeasonAsync(IdHelper.BigBangTheory, 1, TvSeasonMethods.AccountStates).Result;
|
||||
if (season.AccountStates == null || season.AccountStates.Results.All(s => s.EpisodeNumber != 1))
|
||||
{
|
||||
_config.Client.TvEpisodeSetRatingAsync(IdHelper.BigBangTheory, 1, 1, 5).Wait();
|
||||
_config.Client.TvEpisodeSetRatingAsync(IdHelper.BigBangTheory, 1, 1, 5).Sync();
|
||||
|
||||
// Allow TMDb to update cache
|
||||
Thread.Sleep(2000);
|
||||
@ -83,18 +71,18 @@ namespace TMDbLibTests
|
||||
season = _config.Client.GetTvSeasonAsync(IdHelper.BigBangTheory, 1, TvSeasonMethods.AccountStates).Result;
|
||||
}
|
||||
|
||||
Assert.IsNotNull(season.AccountStates);
|
||||
Assert.IsTrue(season.AccountStates.Results.Single(s => s.EpisodeNumber == 1).Rating.HasValue);
|
||||
Assert.IsTrue(Math.Abs(season.AccountStates.Results.Single(s => s.EpisodeNumber == 1).Rating.Value - 5) < double.Epsilon);
|
||||
Assert.NotNull(season.AccountStates);
|
||||
Assert.True(season.AccountStates.Results.Single(s => s.EpisodeNumber == 1).Rating.HasValue);
|
||||
Assert.True(Math.Abs(season.AccountStates.Results.Single(s => s.EpisodeNumber == 1).Rating.Value - 5) < double.Epsilon);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvSeasonExtrasAll()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Account states will only show up if we've done something
|
||||
_config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 5).Wait();
|
||||
_config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 5).Sync();
|
||||
|
||||
TvSeasonMethods combinedEnum = _methods.Keys.Aggregate((methods, tvSeasonMethods) => methods | tvSeasonMethods);
|
||||
TvSeason tvSeason = _config.Client.GetTvSeasonAsync(IdHelper.BreakingBad, 1, combinedEnum).Result;
|
||||
@ -104,7 +92,7 @@ namespace TMDbLibTests
|
||||
TestMethodsHelper.TestAllNotNull(_methods, tvSeason);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvSeasonExtrasExclusive()
|
||||
{
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
@ -114,151 +102,151 @@ namespace TMDbLibTests
|
||||
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetTvSeasonAsync(id, 1, extras).Result, IdHelper.BreakingBad);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvSeasonSeparateExtrasCredits()
|
||||
{
|
||||
Credits credits = _config.Client.GetTvSeasonCreditsAsync(IdHelper.BreakingBad, 1).Result;
|
||||
Assert.IsNotNull(credits);
|
||||
Assert.IsNotNull(credits.Cast);
|
||||
Assert.AreEqual("Walter White", credits.Cast[0].Character);
|
||||
Assert.AreEqual("52542282760ee313280017f9", credits.Cast[0].CreditId);
|
||||
Assert.AreEqual(17419, credits.Cast[0].Id);
|
||||
Assert.AreEqual("Bryan Cranston", credits.Cast[0].Name);
|
||||
Assert.IsNotNull(credits.Cast[0].ProfilePath);
|
||||
Assert.AreEqual(0, credits.Cast[0].Order);
|
||||
Assert.NotNull(credits);
|
||||
Assert.NotNull(credits.Cast);
|
||||
Assert.Equal("Walter White", credits.Cast[0].Character);
|
||||
Assert.Equal("52542282760ee313280017f9", credits.Cast[0].CreditId);
|
||||
Assert.Equal(17419, credits.Cast[0].Id);
|
||||
Assert.Equal("Bryan Cranston", credits.Cast[0].Name);
|
||||
Assert.NotNull(credits.Cast[0].ProfilePath);
|
||||
Assert.Equal(0, credits.Cast[0].Order);
|
||||
|
||||
Crew crewPersonId = credits.Crew.FirstOrDefault(s => s.Id == 1223202);
|
||||
Assert.IsNotNull(crewPersonId);
|
||||
Assert.NotNull(crewPersonId);
|
||||
|
||||
Assert.AreEqual(1223202, crewPersonId.Id);
|
||||
Assert.AreEqual("Production", crewPersonId.Department);
|
||||
Assert.AreEqual("Diane Mercer", crewPersonId.Name);
|
||||
Assert.AreEqual("Producer", crewPersonId.Job);
|
||||
Assert.IsNull(crewPersonId.ProfilePath);
|
||||
Assert.Equal(1223202, crewPersonId.Id);
|
||||
Assert.Equal("Production", crewPersonId.Department);
|
||||
Assert.Equal("Diane Mercer", crewPersonId.Name);
|
||||
Assert.Equal("Producer", crewPersonId.Job);
|
||||
Assert.Null(crewPersonId.ProfilePath);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvSeasonSeparateExtrasExternalIds()
|
||||
{
|
||||
ExternalIds externalIds = _config.Client.GetTvSeasonExternalIdsAsync(IdHelper.BreakingBad, 1).Result;
|
||||
Assert.IsNotNull(externalIds);
|
||||
Assert.AreEqual(3572, externalIds.Id);
|
||||
Assert.AreEqual("/en/breaking_bad_season_1", externalIds.FreebaseId);
|
||||
Assert.AreEqual("/m/05yy27m", externalIds.FreebaseMid);
|
||||
Assert.IsNull(externalIds.ImdbId);
|
||||
Assert.IsNull(externalIds.TvrageId);
|
||||
Assert.AreEqual("30272", externalIds.TvdbId);
|
||||
Assert.NotNull(externalIds);
|
||||
Assert.Equal(3572, externalIds.Id);
|
||||
Assert.Equal("/en/breaking_bad_season_1", externalIds.FreebaseId);
|
||||
Assert.Equal("/m/05yy27m", externalIds.FreebaseMid);
|
||||
Assert.Null(externalIds.ImdbId);
|
||||
Assert.Null(externalIds.TvrageId);
|
||||
Assert.Equal("30272", externalIds.TvdbId);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvSeasonSeparateExtrasImages()
|
||||
{
|
||||
PosterImages images = _config.Client.GetTvSeasonImagesAsync(IdHelper.BreakingBad, 1).Result;
|
||||
Assert.IsNotNull(images);
|
||||
Assert.IsNotNull(images.Posters);
|
||||
Assert.NotNull(images);
|
||||
Assert.NotNull(images.Posters);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvSeasonSeparateExtrasVideos()
|
||||
{
|
||||
ResultContainer<Video> videos = _config.Client.GetTvSeasonVideosAsync(IdHelper.BreakingBad, 1).Result;
|
||||
Assert.IsNotNull(videos);
|
||||
Assert.IsNotNull(videos.Results);
|
||||
Assert.NotNull(videos);
|
||||
Assert.NotNull(videos.Results);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvSeasonEpisodeCount()
|
||||
{
|
||||
TvSeason season = _config.Client.GetTvSeasonAsync(IdHelper.BreakingBad, 1).Result;
|
||||
Assert.IsNotNull(season);
|
||||
Assert.IsNotNull(season.Episodes);
|
||||
Assert.NotNull(season);
|
||||
Assert.NotNull(season.Episodes);
|
||||
|
||||
Assert.AreEqual(season.Episodes.Count, season.EpisodeCount);
|
||||
Assert.Equal(season.Episodes.Count, season.EpisodeCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvSeasonAccountStateRatingSet()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Rate episode 1, 2 and 3 of BreakingBad
|
||||
Assert.IsTrue(_config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 5).Result);
|
||||
Assert.IsTrue(_config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 2, 7).Result);
|
||||
Assert.IsTrue(_config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 3, 3).Result);
|
||||
Assert.True(_config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 5).Result);
|
||||
Assert.True(_config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 2, 7).Result);
|
||||
Assert.True(_config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 3, 3).Result);
|
||||
|
||||
// Wait for TMDb to un-cache our value
|
||||
Thread.Sleep(2000);
|
||||
|
||||
// Fetch out the seasons state
|
||||
ResultContainer<TvEpisodeAccountState> state = _config.Client.GetTvSeasonAccountStateAsync(IdHelper.BreakingBad, 1).Result;
|
||||
Assert.IsNotNull(state);
|
||||
Assert.NotNull(state);
|
||||
|
||||
Assert.IsTrue(Math.Abs(5 - (state.Results.Single(s => s.EpisodeNumber == 1).Rating ?? 0)) < double.Epsilon);
|
||||
Assert.IsTrue(Math.Abs(7 - (state.Results.Single(s => s.EpisodeNumber == 2).Rating ?? 0)) < double.Epsilon);
|
||||
Assert.IsTrue(Math.Abs(3 - (state.Results.Single(s => s.EpisodeNumber == 3).Rating ?? 0)) < double.Epsilon);
|
||||
Assert.True(Math.Abs(5 - (state.Results.Single(s => s.EpisodeNumber == 1).Rating ?? 0)) < double.Epsilon);
|
||||
Assert.True(Math.Abs(7 - (state.Results.Single(s => s.EpisodeNumber == 2).Rating ?? 0)) < double.Epsilon);
|
||||
Assert.True(Math.Abs(3 - (state.Results.Single(s => s.EpisodeNumber == 3).Rating ?? 0)) < double.Epsilon);
|
||||
|
||||
// Test deleting Ratings
|
||||
Assert.IsTrue(_config.Client.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 1).Result);
|
||||
Assert.IsTrue(_config.Client.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 2).Result);
|
||||
Assert.IsTrue(_config.Client.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 3).Result);
|
||||
Assert.True(_config.Client.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 1).Result);
|
||||
Assert.True(_config.Client.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 2).Result);
|
||||
Assert.True(_config.Client.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 3).Result);
|
||||
|
||||
// Wait for TMDb to un-cache our value
|
||||
Thread.Sleep(2000);
|
||||
|
||||
state = _config.Client.GetTvSeasonAccountStateAsync(IdHelper.BreakingBad, 1).Result;
|
||||
Assert.IsNotNull(state);
|
||||
Assert.NotNull(state);
|
||||
|
||||
Assert.IsNull(state.Results.Single(s => s.EpisodeNumber == 1).Rating);
|
||||
Assert.IsNull(state.Results.Single(s => s.EpisodeNumber == 2).Rating);
|
||||
Assert.IsNull(state.Results.Single(s => s.EpisodeNumber == 3).Rating);
|
||||
Assert.Null(state.Results.Single(s => s.EpisodeNumber == 1).Rating);
|
||||
Assert.Null(state.Results.Single(s => s.EpisodeNumber == 2).Rating);
|
||||
Assert.Null(state.Results.Single(s => s.EpisodeNumber == 3).Rating);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvSeasonGetChanges()
|
||||
{
|
||||
ChangesContainer changes = _config.Client.GetTvSeasonChangesAsync(IdHelper.BreakingBadSeason1Id).Result;
|
||||
Assert.IsNotNull(changes);
|
||||
Assert.IsNotNull(changes.Changes);
|
||||
Assert.NotNull(changes);
|
||||
Assert.NotNull(changes.Changes);
|
||||
}
|
||||
|
||||
private void TestBreakingBadBaseProperties(TvSeason tvSeason)
|
||||
{
|
||||
Assert.IsNotNull(tvSeason);
|
||||
Assert.IsNotNull(tvSeason.Id);
|
||||
Assert.AreEqual(1, tvSeason.SeasonNumber);
|
||||
Assert.AreEqual("Season 1", tvSeason.Name);
|
||||
Assert.IsNotNull(tvSeason.AirDate);
|
||||
Assert.IsNotNull(tvSeason.Overview);
|
||||
Assert.IsNotNull(tvSeason.PosterPath);
|
||||
Assert.NotNull(tvSeason);
|
||||
Assert.NotNull(tvSeason.Id);
|
||||
Assert.Equal(1, tvSeason.SeasonNumber);
|
||||
Assert.Equal("Season 1", tvSeason.Name);
|
||||
Assert.NotNull(tvSeason.AirDate);
|
||||
Assert.NotNull(tvSeason.Overview);
|
||||
Assert.NotNull(tvSeason.PosterPath);
|
||||
|
||||
Assert.IsNotNull(tvSeason.Episodes);
|
||||
Assert.AreEqual(7, tvSeason.Episodes.Count);
|
||||
Assert.IsNotNull(tvSeason.Episodes[0].Id);
|
||||
Assert.AreEqual(1, tvSeason.Episodes[0].EpisodeNumber);
|
||||
Assert.AreEqual("Pilot", tvSeason.Episodes[0].Name);
|
||||
Assert.IsNotNull(tvSeason.Episodes[0].Overview);
|
||||
Assert.IsNull(tvSeason.Episodes[0].ProductionCode);
|
||||
Assert.AreEqual(1, tvSeason.Episodes[0].SeasonNumber);
|
||||
Assert.IsNotNull(tvSeason.Episodes[0].StillPath);
|
||||
Assert.NotNull(tvSeason.Episodes);
|
||||
Assert.Equal(7, tvSeason.Episodes.Count);
|
||||
Assert.NotNull(tvSeason.Episodes[0].Id);
|
||||
Assert.Equal(1, tvSeason.Episodes[0].EpisodeNumber);
|
||||
Assert.Equal("Pilot", tvSeason.Episodes[0].Name);
|
||||
Assert.NotNull(tvSeason.Episodes[0].Overview);
|
||||
Assert.Null(tvSeason.Episodes[0].ProductionCode);
|
||||
Assert.Equal(1, tvSeason.Episodes[0].SeasonNumber);
|
||||
Assert.NotNull(tvSeason.Episodes[0].StillPath);
|
||||
}
|
||||
|
||||
//[TestMethod]
|
||||
//[Fact]
|
||||
//public void TestMoviesLanguage()
|
||||
//{
|
||||
// Movie movie = _config.Client.GetMovieAsync(AGoodDayToDieHard);
|
||||
// Movie movieItalian = _config.Client.GetMovieAsync(AGoodDayToDieHard, "it");
|
||||
|
||||
// Assert.IsNotNull(movie);
|
||||
// Assert.IsNotNull(movieItalian);
|
||||
// Assert.NotNull(movie);
|
||||
// Assert.NotNull(movieItalian);
|
||||
|
||||
// Assert.AreEqual("A Good Day to Die Hard", movie.Title);
|
||||
// Assert.AreNotEqual(movie.Title, movieItalian.Title);
|
||||
// Assert.Equal("A Good Day to Die Hard", movie.Title);
|
||||
// Assert.NotEqual(movie.Title, movieItalian.Title);
|
||||
|
||||
// // Test all extras, ensure none of them exist
|
||||
// foreach (Func<Movie, object> selector in _methods.Values)
|
||||
// {
|
||||
// Assert.IsNull(selector(movie));
|
||||
// Assert.IsNull(selector(movieItalian));
|
||||
// Assert.Null(selector(movie));
|
||||
// Assert.Null(selector(movieItalian));
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.Movies;
|
||||
@ -15,41 +15,29 @@ using Credits = TMDbLib.Objects.TvShows.Credits;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientTvShowTests : TestBase
|
||||
{
|
||||
private static Dictionary<TvShowMethods, Func<TvShow, object>> _methods;
|
||||
private TestConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public override void Initiator()
|
||||
private readonly TestConfig _config;
|
||||
|
||||
public ClientTvShowTests()
|
||||
{
|
||||
base.Initiator();
|
||||
|
||||
_config = new TestConfig();
|
||||
|
||||
_methods = new Dictionary<TvShowMethods, Func<TvShow, object>>
|
||||
{
|
||||
[TvShowMethods.Credits] = tvShow => tvShow.Credits,
|
||||
[TvShowMethods.Images] = tvShow => tvShow.Images,
|
||||
[TvShowMethods.ExternalIds] = tvShow => tvShow.ExternalIds,
|
||||
[TvShowMethods.ContentRatings] = tvShow => tvShow.ContentRatings,
|
||||
[TvShowMethods.AlternativeTitles] = tvShow => tvShow.AlternativeTitles,
|
||||
[TvShowMethods.Keywords] = tvShow => tvShow.Keywords,
|
||||
[TvShowMethods.Changes] = tvShow => tvShow.Changes,
|
||||
[TvShowMethods.AccountStates] = tvShow => tvShow.AccountStates
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on test class initialization
|
||||
/// </summary>
|
||||
[ClassInitialize]
|
||||
public static void InitialInitiator(TestContext context)
|
||||
{
|
||||
_methods = new Dictionary<TvShowMethods, Func<TvShow, object>>();
|
||||
_methods[TvShowMethods.Credits] = tvShow => tvShow.Credits;
|
||||
_methods[TvShowMethods.Images] = tvShow => tvShow.Images;
|
||||
_methods[TvShowMethods.ExternalIds] = tvShow => tvShow.ExternalIds;
|
||||
_methods[TvShowMethods.ContentRatings] = tvShow => tvShow.ContentRatings;
|
||||
_methods[TvShowMethods.AlternativeTitles] = tvShow => tvShow.AlternativeTitles;
|
||||
_methods[TvShowMethods.Keywords] = tvShow => tvShow.Keywords;
|
||||
_methods[TvShowMethods.Changes] = tvShow => tvShow.Changes;
|
||||
_methods[TvShowMethods.AccountStates] = tvShow => tvShow.AccountStates;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowExtrasNone()
|
||||
{
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
@ -61,16 +49,16 @@ namespace TMDbLibTests
|
||||
|
||||
// Test all extras, ensure none of them are populated
|
||||
foreach (Func<TvShow, object> selector in _methods.Values)
|
||||
Assert.IsNull(selector(tvShow));
|
||||
Assert.Null(selector(tvShow));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowExtrasAll()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Account states will only show up if we've done something
|
||||
_config.Client.TvShowSetRatingAsync(IdHelper.BreakingBad, 5).Wait();
|
||||
_config.Client.TvShowSetRatingAsync(IdHelper.BreakingBad, 5).Sync();
|
||||
|
||||
TvShowMethods combinedEnum = _methods.Keys.Aggregate((methods, tvShowMethods) => methods | tvShowMethods);
|
||||
TvShow tvShow = _config.Client.GetTvShowAsync(IdHelper.BreakingBad, combinedEnum).Result;
|
||||
@ -80,120 +68,120 @@ namespace TMDbLibTests
|
||||
TestMethodsHelper.TestAllNotNull(_methods, tvShow);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowSeparateExtrasCredits()
|
||||
{
|
||||
Credits credits = _config.Client.GetTvShowCreditsAsync(IdHelper.BreakingBad).Result;
|
||||
|
||||
Assert.IsNotNull(credits);
|
||||
Assert.IsNotNull(credits.Cast);
|
||||
Assert.AreEqual(IdHelper.BreakingBad, credits.Id);
|
||||
Assert.NotNull(credits);
|
||||
Assert.NotNull(credits.Cast);
|
||||
Assert.Equal(IdHelper.BreakingBad, credits.Id);
|
||||
|
||||
Cast castPerson = credits.Cast[0];
|
||||
Assert.AreEqual("Walter White", castPerson.Character);
|
||||
Assert.AreEqual("52542282760ee313280017f9", castPerson.CreditId);
|
||||
Assert.AreEqual(17419, castPerson.Id);
|
||||
Assert.AreEqual("Bryan Cranston", castPerson.Name);
|
||||
Assert.IsNotNull(castPerson.ProfilePath);
|
||||
Assert.AreEqual(0, castPerson.Order);
|
||||
Assert.Equal("Walter White", castPerson.Character);
|
||||
Assert.Equal("52542282760ee313280017f9", castPerson.CreditId);
|
||||
Assert.Equal(17419, castPerson.Id);
|
||||
Assert.Equal("Bryan Cranston", castPerson.Name);
|
||||
Assert.NotNull(castPerson.ProfilePath);
|
||||
Assert.Equal(0, castPerson.Order);
|
||||
|
||||
Assert.IsNotNull(credits.Crew);
|
||||
Assert.NotNull(credits.Crew);
|
||||
|
||||
Crew crewPerson = credits.Crew.FirstOrDefault(s => s.Id == 66633);
|
||||
Assert.IsNotNull(crewPerson);
|
||||
Assert.NotNull(crewPerson);
|
||||
|
||||
Assert.AreEqual(66633, crewPerson.Id);
|
||||
Assert.AreEqual("52542287760ee31328001af1", crewPerson.CreditId);
|
||||
Assert.AreEqual("Production", crewPerson.Department);
|
||||
Assert.AreEqual("Vince Gilligan", crewPerson.Name);
|
||||
Assert.AreEqual("Executive Producer", crewPerson.Job);
|
||||
Assert.IsNotNull(crewPerson.ProfilePath);
|
||||
Assert.Equal(66633, crewPerson.Id);
|
||||
Assert.Equal("52542287760ee31328001af1", crewPerson.CreditId);
|
||||
Assert.Equal("Production", crewPerson.Department);
|
||||
Assert.Equal("Vince Gilligan", crewPerson.Name);
|
||||
Assert.Equal("Executive Producer", crewPerson.Job);
|
||||
Assert.NotNull(crewPerson.ProfilePath);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowSeparateExtrasExternalIds()
|
||||
{
|
||||
ExternalIds externalIds = _config.Client.GetTvShowExternalIdsAsync(IdHelper.BreakingBad).Result;
|
||||
Assert.IsNotNull(externalIds);
|
||||
Assert.AreEqual(1396, externalIds.Id);
|
||||
Assert.AreEqual("/en/breaking_bad", externalIds.FreebaseId);
|
||||
Assert.AreEqual("/m/03d34x8", externalIds.FreebaseMid);
|
||||
Assert.AreEqual("tt0903747", externalIds.ImdbId);
|
||||
Assert.AreEqual("18164", externalIds.TvrageId);
|
||||
Assert.AreEqual("81189", externalIds.TvdbId);
|
||||
Assert.NotNull(externalIds);
|
||||
Assert.Equal(1396, externalIds.Id);
|
||||
Assert.Equal("/en/breaking_bad", externalIds.FreebaseId);
|
||||
Assert.Equal("/m/03d34x8", externalIds.FreebaseMid);
|
||||
Assert.Equal("tt0903747", externalIds.ImdbId);
|
||||
Assert.Equal("18164", externalIds.TvrageId);
|
||||
Assert.Equal("81189", externalIds.TvdbId);
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowSeparateExtrasContentRatings()
|
||||
{
|
||||
ResultContainer<ContentRating> contentRatings = _config.Client.GetTvShowContentRatingsAsync(IdHelper.BreakingBad).Result;
|
||||
Assert.IsNotNull(contentRatings);
|
||||
Assert.AreEqual(IdHelper.BreakingBad, contentRatings.Id);
|
||||
Assert.NotNull(contentRatings);
|
||||
Assert.Equal(IdHelper.BreakingBad, contentRatings.Id);
|
||||
|
||||
ContentRating contentRating = contentRatings.Results.FirstOrDefault(r => r.Iso_3166_1.Equals("US"));
|
||||
Assert.IsNotNull(contentRating);
|
||||
Assert.AreEqual("TV-MA", contentRating.Rating);
|
||||
Assert.NotNull(contentRating);
|
||||
Assert.Equal("TV-MA", contentRating.Rating);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowSeparateExtrasAlternativeTitles()
|
||||
{
|
||||
ResultContainer<AlternativeTitle> alternativeTitles = _config.Client.GetTvShowAlternativeTitlesAsync(IdHelper.BreakingBad).Result;
|
||||
Assert.IsNotNull(alternativeTitles);
|
||||
Assert.AreEqual(IdHelper.BreakingBad, alternativeTitles.Id);
|
||||
Assert.NotNull(alternativeTitles);
|
||||
Assert.Equal(IdHelper.BreakingBad, alternativeTitles.Id);
|
||||
|
||||
AlternativeTitle alternativeTitle = alternativeTitles.Results.FirstOrDefault(r => r.Iso_3166_1.Equals("BR"));
|
||||
Assert.IsNotNull(alternativeTitle);
|
||||
Assert.AreEqual("Breaking Bad: A Química do Mal", alternativeTitle.Title);
|
||||
AlternativeTitle alternativeTitle = alternativeTitles.Results.FirstOrDefault(r => r.Iso_3166_1.Equals("IT"));
|
||||
Assert.NotNull(alternativeTitle);
|
||||
Assert.Equal("Breaking Bad - Reazioni collaterali", alternativeTitle.Title);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowSeparateExtrasKeywords()
|
||||
{
|
||||
ResultContainer<Keyword> keywords = _config.Client.GetTvShowKeywordsAsync(IdHelper.BreakingBad).Result;
|
||||
Assert.IsNotNull(keywords);
|
||||
Assert.AreEqual(IdHelper.BreakingBad, keywords.Id);
|
||||
Assert.NotNull(keywords);
|
||||
Assert.Equal(IdHelper.BreakingBad, keywords.Id);
|
||||
|
||||
Keyword keyword = keywords.Results.FirstOrDefault(r => r.Id == 41525);
|
||||
Assert.IsNotNull(keyword);
|
||||
Assert.AreEqual("high school teacher", keyword.Name);
|
||||
Assert.NotNull(keyword);
|
||||
Assert.Equal("high school teacher", keyword.Name);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowSeparateExtrasTranslations()
|
||||
{
|
||||
TranslationsContainer translations = _config.Client.GetTvShowTranslationsAsync(IdHelper.BreakingBad).Result;
|
||||
Assert.IsNotNull(translations);
|
||||
Assert.AreEqual(IdHelper.BreakingBad, translations.Id);
|
||||
Assert.NotNull(translations);
|
||||
Assert.Equal(IdHelper.BreakingBad, translations.Id);
|
||||
|
||||
Translation translation = translations.Translations.FirstOrDefault(r => r.Iso_639_1 == "hr");
|
||||
Assert.IsNotNull(translation);
|
||||
Assert.AreEqual("Croatian", translation.EnglishName);
|
||||
Assert.AreEqual("hr", translation.Iso_639_1);
|
||||
Assert.AreEqual("Hrvatski", translation.Name);
|
||||
Assert.NotNull(translation);
|
||||
Assert.Equal("Croatian", translation.EnglishName);
|
||||
Assert.Equal("hr", translation.Iso_639_1);
|
||||
Assert.Equal("Hrvatski", translation.Name);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowSeparateExtrasVideos()
|
||||
{
|
||||
ResultContainer<Video> videos = _config.Client.GetTvShowVideosAsync(IdHelper.BreakingBad).Result;
|
||||
Assert.IsNotNull(videos);
|
||||
Assert.AreEqual(IdHelper.BreakingBad, videos.Id);
|
||||
Assert.NotNull(videos);
|
||||
Assert.Equal(IdHelper.BreakingBad, videos.Id);
|
||||
|
||||
Video video = videos.Results.FirstOrDefault(r => r.Id == "5335e299c3a368265000001d");
|
||||
Assert.IsNotNull(video);
|
||||
Assert.NotNull(video);
|
||||
|
||||
Assert.AreEqual("5335e299c3a368265000001d", video.Id);
|
||||
Assert.AreEqual("en", video.Iso_639_1);
|
||||
Assert.AreEqual("6OdIbPMU720", video.Key);
|
||||
Assert.AreEqual("Opening Credits (Short)", video.Name);
|
||||
Assert.AreEqual("YouTube", video.Site);
|
||||
Assert.AreEqual(480, video.Size);
|
||||
Assert.AreEqual("Opening Credits", video.Type);
|
||||
Assert.Equal("5335e299c3a368265000001d", video.Id);
|
||||
Assert.Equal("en", video.Iso_639_1);
|
||||
Assert.Equal("6OdIbPMU720", video.Key);
|
||||
Assert.Equal("Opening Credits (Short)", video.Name);
|
||||
Assert.Equal("YouTube", video.Site);
|
||||
Assert.Equal(480, video.Size);
|
||||
Assert.Equal("Opening Credits", video.Type);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowSeparateExtrasAccountState()
|
||||
{
|
||||
// Test the custom parsing code for Account State rating
|
||||
@ -202,7 +190,7 @@ namespace TMDbLibTests
|
||||
TvShow show = _config.Client.GetTvShowAsync(IdHelper.BigBangTheory, TvShowMethods.AccountStates).Result;
|
||||
if (show.AccountStates == null || !show.AccountStates.Rating.HasValue)
|
||||
{
|
||||
_config.Client.TvShowSetRatingAsync(IdHelper.BigBangTheory, 5).Wait();
|
||||
_config.Client.TvShowSetRatingAsync(IdHelper.BigBangTheory, 5).Sync();
|
||||
|
||||
// Allow TMDb to update cache
|
||||
Thread.Sleep(2000);
|
||||
@ -210,160 +198,160 @@ namespace TMDbLibTests
|
||||
show = _config.Client.GetTvShowAsync(IdHelper.BigBangTheory, TvShowMethods.AccountStates).Result;
|
||||
}
|
||||
|
||||
Assert.IsNotNull(show.AccountStates);
|
||||
Assert.IsTrue(show.AccountStates.Rating.HasValue);
|
||||
Assert.IsTrue(Math.Abs(show.AccountStates.Rating.Value - 5) < double.Epsilon);
|
||||
Assert.NotNull(show.AccountStates);
|
||||
Assert.True(show.AccountStates.Rating.HasValue);
|
||||
Assert.True(Math.Abs(show.AccountStates.Rating.Value - 5) < double.Epsilon);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowSeparateExtrasImages()
|
||||
{
|
||||
ImagesWithId images = _config.Client.GetTvShowImagesAsync(IdHelper.BreakingBad).Result;
|
||||
Assert.IsNotNull(images);
|
||||
Assert.IsNotNull(images.Backdrops);
|
||||
Assert.IsNotNull(images.Posters);
|
||||
Assert.NotNull(images);
|
||||
Assert.NotNull(images.Backdrops);
|
||||
Assert.NotNull(images.Posters);
|
||||
}
|
||||
|
||||
private void TestBreakingBadBaseProperties(TvShow tvShow)
|
||||
{
|
||||
Assert.IsNotNull(tvShow);
|
||||
Assert.IsNotNull(tvShow.Id);
|
||||
Assert.AreEqual("Breaking Bad", tvShow.Name);
|
||||
Assert.AreEqual("Breaking Bad", tvShow.OriginalName);
|
||||
Assert.IsNotNull(tvShow.Overview);
|
||||
Assert.IsNotNull(tvShow.Homepage);
|
||||
Assert.AreEqual(new DateTime(2008, 01, 19), tvShow.FirstAirDate);
|
||||
Assert.AreEqual(new DateTime(2013, 9, 29), tvShow.LastAirDate);
|
||||
Assert.AreEqual(false, tvShow.InProduction);
|
||||
Assert.AreEqual("Ended", tvShow.Status);
|
||||
Assert.AreEqual("Scripted", tvShow.Type);
|
||||
Assert.AreEqual("en", tvShow.OriginalLanguage);
|
||||
Assert.NotNull(tvShow);
|
||||
Assert.NotNull(tvShow.Id);
|
||||
Assert.Equal("Breaking Bad", tvShow.Name);
|
||||
Assert.Equal("Breaking Bad", tvShow.OriginalName);
|
||||
Assert.NotNull(tvShow.Overview);
|
||||
Assert.NotNull(tvShow.Homepage);
|
||||
Assert.Equal(new DateTime(2008, 01, 19), tvShow.FirstAirDate);
|
||||
Assert.Equal(new DateTime(2013, 9, 29), tvShow.LastAirDate);
|
||||
Assert.Equal(false, tvShow.InProduction);
|
||||
Assert.Equal("Ended", tvShow.Status);
|
||||
Assert.Equal("Scripted", tvShow.Type);
|
||||
Assert.Equal("en", tvShow.OriginalLanguage);
|
||||
|
||||
Assert.IsNotNull(tvShow.ProductionCompanies);
|
||||
Assert.AreEqual(3, tvShow.ProductionCompanies.Count);
|
||||
Assert.AreEqual(2605, tvShow.ProductionCompanies[0].Id);
|
||||
Assert.AreEqual("Gran Via Productions", tvShow.ProductionCompanies[0].Name);
|
||||
Assert.NotNull(tvShow.ProductionCompanies);
|
||||
Assert.Equal(3, tvShow.ProductionCompanies.Count);
|
||||
Assert.Equal(2605, tvShow.ProductionCompanies[0].Id);
|
||||
Assert.Equal("Gran Via Productions", tvShow.ProductionCompanies[0].Name);
|
||||
|
||||
Assert.IsNotNull(tvShow.CreatedBy);
|
||||
Assert.AreEqual(1, tvShow.CreatedBy.Count);
|
||||
Assert.AreEqual(66633, tvShow.CreatedBy[0].Id);
|
||||
Assert.AreEqual("Vince Gilligan", tvShow.CreatedBy[0].Name);
|
||||
Assert.NotNull(tvShow.CreatedBy);
|
||||
Assert.Equal(1, tvShow.CreatedBy.Count);
|
||||
Assert.Equal(66633, tvShow.CreatedBy[0].Id);
|
||||
Assert.Equal("Vince Gilligan", tvShow.CreatedBy[0].Name);
|
||||
|
||||
Assert.IsNotNull(tvShow.EpisodeRunTime);
|
||||
Assert.AreEqual(2, tvShow.EpisodeRunTime.Count);
|
||||
Assert.NotNull(tvShow.EpisodeRunTime);
|
||||
Assert.Equal(2, tvShow.EpisodeRunTime.Count);
|
||||
|
||||
Assert.IsNotNull(tvShow.Genres);
|
||||
Assert.AreEqual(18, tvShow.Genres[0].Id);
|
||||
Assert.AreEqual("Drama", tvShow.Genres[0].Name);
|
||||
Assert.NotNull(tvShow.Genres);
|
||||
Assert.Equal(18, tvShow.Genres[0].Id);
|
||||
Assert.Equal("Drama", tvShow.Genres[0].Name);
|
||||
|
||||
Assert.IsNotNull(tvShow.Languages);
|
||||
Assert.AreEqual("en", tvShow.Languages[0]);
|
||||
Assert.NotNull(tvShow.Languages);
|
||||
Assert.Equal("en", tvShow.Languages[0]);
|
||||
|
||||
Assert.IsNotNull(tvShow.Networks);
|
||||
Assert.AreEqual(1, tvShow.Networks.Count);
|
||||
Assert.AreEqual(174, tvShow.Networks[0].Id);
|
||||
Assert.AreEqual("AMC", tvShow.Networks[0].Name);
|
||||
Assert.NotNull(tvShow.Networks);
|
||||
Assert.Equal(1, tvShow.Networks.Count);
|
||||
Assert.Equal(174, tvShow.Networks[0].Id);
|
||||
Assert.Equal("AMC", tvShow.Networks[0].Name);
|
||||
|
||||
Assert.IsNotNull(tvShow.OriginCountry);
|
||||
Assert.AreEqual(1, tvShow.OriginCountry.Count);
|
||||
Assert.AreEqual("US", tvShow.OriginCountry[0]);
|
||||
Assert.NotNull(tvShow.OriginCountry);
|
||||
Assert.Equal(1, tvShow.OriginCountry.Count);
|
||||
Assert.Equal("US", tvShow.OriginCountry[0]);
|
||||
|
||||
Assert.IsNotNull(tvShow.Seasons);
|
||||
Assert.AreEqual(6, tvShow.Seasons.Count);
|
||||
Assert.AreEqual(0, tvShow.Seasons[0].SeasonNumber);
|
||||
Assert.AreEqual(1, tvShow.Seasons[1].SeasonNumber);
|
||||
Assert.IsNull(tvShow.Seasons[1].Episodes);
|
||||
Assert.NotNull(tvShow.Seasons);
|
||||
Assert.Equal(6, tvShow.Seasons.Count);
|
||||
Assert.Equal(0, tvShow.Seasons[0].SeasonNumber);
|
||||
Assert.Equal(1, tvShow.Seasons[1].SeasonNumber);
|
||||
Assert.Null(tvShow.Seasons[1].Episodes);
|
||||
|
||||
Assert.AreEqual(62, tvShow.NumberOfEpisodes);
|
||||
Assert.AreEqual(5, tvShow.NumberOfSeasons);
|
||||
Assert.Equal(62, tvShow.NumberOfEpisodes);
|
||||
Assert.Equal(5, tvShow.NumberOfSeasons);
|
||||
|
||||
Assert.IsNotNull(tvShow.PosterPath);
|
||||
Assert.IsNotNull(tvShow.BackdropPath);
|
||||
Assert.NotNull(tvShow.PosterPath);
|
||||
Assert.NotNull(tvShow.BackdropPath);
|
||||
|
||||
Assert.AreNotEqual(0, tvShow.Popularity);
|
||||
Assert.AreNotEqual(0, tvShow.VoteAverage);
|
||||
Assert.AreNotEqual(0, tvShow.VoteAverage);
|
||||
Assert.NotEqual(0, tvShow.Popularity);
|
||||
Assert.NotEqual(0, tvShow.VoteAverage);
|
||||
Assert.NotEqual(0, tvShow.VoteAverage);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowPopular()
|
||||
{
|
||||
TestHelpers.SearchPages(i => _config.Client.GetTvShowPopularAsync(i).Result);
|
||||
|
||||
SearchContainer<SearchTv> result = _config.Client.GetTvShowPopularAsync().Result;
|
||||
Assert.IsNotNull(result.Results[0].Id);
|
||||
Assert.IsNotNull(result.Results[0].Name);
|
||||
Assert.IsNotNull(result.Results[0].OriginalName);
|
||||
Assert.IsNotNull(result.Results[0].FirstAirDate);
|
||||
Assert.IsNotNull(result.Results[0].PosterPath);
|
||||
Assert.IsNotNull(result.Results[0].BackdropPath);
|
||||
SearchContainer<SearchTv> result = _config.Client.GetTvShowPopularAsync().Sync();
|
||||
Assert.NotNull(result.Results[0].Id);
|
||||
Assert.NotNull(result.Results[0].Name);
|
||||
Assert.NotNull(result.Results[0].OriginalName);
|
||||
Assert.NotNull(result.Results[0].FirstAirDate);
|
||||
Assert.NotNull(result.Results[0].PosterPath);
|
||||
Assert.NotNull(result.Results[0].BackdropPath);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowSeasonCount()
|
||||
{
|
||||
TvShow tvShow = _config.Client.GetTvShowAsync(1668).Result;
|
||||
Assert.AreEqual(tvShow.Seasons[1].EpisodeCount, 24);
|
||||
Assert.Equal(tvShow.Seasons[1].EpisodeCount, 24);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowVideos()
|
||||
{
|
||||
TvShow tvShow = _config.Client.GetTvShowAsync(1668, TvShowMethods.Videos).Result;
|
||||
Assert.IsNotNull(tvShow.Videos);
|
||||
Assert.IsNotNull(tvShow.Videos.Results);
|
||||
Assert.IsNotNull(tvShow.Videos.Results[0]);
|
||||
Assert.NotNull(tvShow.Videos);
|
||||
Assert.NotNull(tvShow.Videos.Results);
|
||||
Assert.NotNull(tvShow.Videos.Results[0]);
|
||||
|
||||
Assert.AreEqual("552e1b53c3a3686c4e00207b", tvShow.Videos.Results[0].Id);
|
||||
Assert.AreEqual("en", tvShow.Videos.Results[0].Iso_639_1);
|
||||
Assert.AreEqual("lGTOru7pwL8", tvShow.Videos.Results[0].Key);
|
||||
Assert.AreEqual("Friends - Opening", tvShow.Videos.Results[0].Name);
|
||||
Assert.AreEqual("YouTube", tvShow.Videos.Results[0].Site);
|
||||
Assert.AreEqual(360, tvShow.Videos.Results[0].Size);
|
||||
Assert.AreEqual("Opening Credits", tvShow.Videos.Results[0].Type);
|
||||
Assert.Equal("552e1b53c3a3686c4e00207b", tvShow.Videos.Results[0].Id);
|
||||
Assert.Equal("en", tvShow.Videos.Results[0].Iso_639_1);
|
||||
Assert.Equal("lGTOru7pwL8", tvShow.Videos.Results[0].Key);
|
||||
Assert.Equal("Friends - Opening", tvShow.Videos.Results[0].Name);
|
||||
Assert.Equal("YouTube", tvShow.Videos.Results[0].Site);
|
||||
Assert.Equal(360, tvShow.Videos.Results[0].Size);
|
||||
Assert.Equal("Opening Credits", tvShow.Videos.Results[0].Type);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowTranslations()
|
||||
{
|
||||
TranslationsContainer translations = _config.Client.GetTvShowTranslationsAsync(1668).Result;
|
||||
|
||||
Assert.AreEqual(1668, translations.Id);
|
||||
Assert.Equal(1668, translations.Id);
|
||||
Translation translation = translations.Translations.SingleOrDefault(s => s.Iso_639_1 == "hr");
|
||||
Assert.IsNotNull(translation);
|
||||
Assert.NotNull(translation);
|
||||
|
||||
Assert.AreEqual("Croatian", translation.EnglishName);
|
||||
Assert.AreEqual("hr", translation.Iso_639_1);
|
||||
Assert.AreEqual("Hrvatski", translation.Name);
|
||||
Assert.Equal("Croatian", translation.EnglishName);
|
||||
Assert.Equal("hr", translation.Iso_639_1);
|
||||
Assert.Equal("Hrvatski", translation.Name);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowSimilars()
|
||||
{
|
||||
SearchContainer<SearchTv> tvShow = _config.Client.GetTvShowSimilarAsync(1668).Result;
|
||||
|
||||
Assert.IsNotNull(tvShow);
|
||||
Assert.IsNotNull(tvShow.Results);
|
||||
Assert.NotNull(tvShow);
|
||||
Assert.NotNull(tvShow.Results);
|
||||
|
||||
SearchTv item = tvShow.Results.SingleOrDefault(s => s.Id == 1100);
|
||||
Assert.IsNotNull(item);
|
||||
Assert.NotNull(item);
|
||||
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(item.BackdropPath), "item.BackdropPath was not a valid image path, was: " + item.BackdropPath);
|
||||
Assert.AreEqual(1100, item.Id);
|
||||
Assert.AreEqual("How I Met Your Mother", item.OriginalName);
|
||||
Assert.AreEqual(new DateTime(2005, 09, 19), item.FirstAirDate);
|
||||
Assert.IsTrue(TestImagesHelpers.TestImagePath(item.PosterPath), "item.PosterPath was not a valid image path, was: " + item.PosterPath);
|
||||
Assert.IsTrue(item.Popularity > 0);
|
||||
Assert.AreEqual("How I Met Your Mother", item.Name);
|
||||
Assert.IsTrue(item.VoteAverage > 0);
|
||||
Assert.IsTrue(item.VoteCount > 0);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.BackdropPath), "item.BackdropPath was not a valid image path, was: " + item.BackdropPath);
|
||||
Assert.Equal(1100, item.Id);
|
||||
Assert.Equal("How I Met Your Mother", item.OriginalName);
|
||||
Assert.Equal(new DateTime(2005, 09, 19), item.FirstAirDate);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.PosterPath), "item.PosterPath was not a valid image path, was: " + item.PosterPath);
|
||||
Assert.True(item.Popularity > 0);
|
||||
Assert.Equal("How I Met Your Mother", item.Name);
|
||||
Assert.True(item.VoteAverage > 0);
|
||||
Assert.True(item.VoteCount > 0);
|
||||
|
||||
Assert.IsNotNull(item.OriginCountry);
|
||||
Assert.AreEqual(1, item.OriginCountry.Count);
|
||||
Assert.IsTrue(item.OriginCountry.Contains("US"));
|
||||
Assert.NotNull(item.OriginCountry);
|
||||
Assert.Equal(1, item.OriginCountry.Count);
|
||||
Assert.True(item.OriginCountry.Contains("US"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowTopRated()
|
||||
{
|
||||
// This test might fail with inconsistent information from the pages due to a caching problem in the API.
|
||||
@ -374,24 +362,24 @@ namespace TMDbLibTests
|
||||
// And as we get more ratings I increase that limit so we get more accurate results.
|
||||
TestHelpers.SearchPages(i => _config.Client.GetTvShowTopRatedAsync(i).Result);
|
||||
|
||||
SearchContainer<SearchTv> result = _config.Client.GetTvShowTopRatedAsync().Result;
|
||||
Assert.IsNotNull(result.Results[0].Id);
|
||||
Assert.IsNotNull(result.Results[0].Name);
|
||||
Assert.IsNotNull(result.Results[0].OriginalName);
|
||||
Assert.IsNotNull(result.Results[0].FirstAirDate);
|
||||
Assert.IsNotNull(result.Results[0].PosterPath);
|
||||
Assert.IsNotNull(result.Results[0].BackdropPath);
|
||||
SearchContainer<SearchTv> result = _config.Client.GetTvShowTopRatedAsync().Sync();
|
||||
Assert.NotNull(result.Results[0].Id);
|
||||
Assert.NotNull(result.Results[0].Name);
|
||||
Assert.NotNull(result.Results[0].OriginalName);
|
||||
Assert.NotNull(result.Results[0].FirstAirDate);
|
||||
Assert.NotNull(result.Results[0].PosterPath);
|
||||
Assert.NotNull(result.Results[0].BackdropPath);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowLatest()
|
||||
{
|
||||
TvShow tvShow = _config.Client.GetLatestTvShowAsync().Result;
|
||||
TvShow tvShow = _config.Client.GetLatestTvShowAsync().Sync();
|
||||
|
||||
Assert.IsNotNull(tvShow);
|
||||
Assert.NotNull(tvShow);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowLists()
|
||||
{
|
||||
foreach (TvShowListType type in Enum.GetValues(typeof(TvShowListType)).OfType<TvShowListType>())
|
||||
@ -400,7 +388,7 @@ namespace TMDbLibTests
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowAccountStateFavoriteSet()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
@ -408,7 +396,7 @@ namespace TMDbLibTests
|
||||
|
||||
// Remove the favourite
|
||||
if (accountState.Favorite)
|
||||
_config.Client.AccountChangeFavoriteStatusAsync(MediaType.TVShow, IdHelper.BreakingBad, false).Wait();
|
||||
_config.Client.AccountChangeFavoriteStatusAsync(MediaType.TVShow, IdHelper.BreakingBad, false).Sync();
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
@ -416,22 +404,22 @@ namespace TMDbLibTests
|
||||
// Test that the movie is NOT favourited
|
||||
accountState = _config.Client.GetTvShowAccountStateAsync(IdHelper.BreakingBad).Result;
|
||||
|
||||
Assert.AreEqual(IdHelper.BreakingBad, accountState.Id);
|
||||
Assert.IsFalse(accountState.Favorite);
|
||||
Assert.Equal(IdHelper.BreakingBad, accountState.Id);
|
||||
Assert.False(accountState.Favorite);
|
||||
|
||||
// Favourite the movie
|
||||
_config.Client.AccountChangeFavoriteStatusAsync(MediaType.TVShow, IdHelper.BreakingBad, true).Wait();
|
||||
_config.Client.AccountChangeFavoriteStatusAsync(MediaType.TVShow, IdHelper.BreakingBad, true).Sync();
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
// Test that the movie IS favourited
|
||||
accountState = _config.Client.GetTvShowAccountStateAsync(IdHelper.BreakingBad).Result;
|
||||
Assert.AreEqual(IdHelper.BreakingBad, accountState.Id);
|
||||
Assert.IsTrue(accountState.Favorite);
|
||||
Assert.Equal(IdHelper.BreakingBad, accountState.Id);
|
||||
Assert.True(accountState.Favorite);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowAccountStateWatchlistSet()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
@ -439,7 +427,7 @@ namespace TMDbLibTests
|
||||
|
||||
// Remove the watchlist
|
||||
if (accountState.Watchlist)
|
||||
_config.Client.AccountChangeWatchlistStatusAsync(MediaType.TVShow, IdHelper.BreakingBad, false).Wait();
|
||||
_config.Client.AccountChangeWatchlistStatusAsync(MediaType.TVShow, IdHelper.BreakingBad, false).Sync();
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
@ -447,22 +435,22 @@ namespace TMDbLibTests
|
||||
// Test that the movie is NOT watchlisted
|
||||
accountState = _config.Client.GetTvShowAccountStateAsync(IdHelper.BreakingBad).Result;
|
||||
|
||||
Assert.AreEqual(IdHelper.BreakingBad, accountState.Id);
|
||||
Assert.IsFalse(accountState.Watchlist);
|
||||
Assert.Equal(IdHelper.BreakingBad, accountState.Id);
|
||||
Assert.False(accountState.Watchlist);
|
||||
|
||||
// Watchlist the movie
|
||||
_config.Client.AccountChangeWatchlistStatusAsync(MediaType.TVShow, IdHelper.BreakingBad, true).Wait();
|
||||
_config.Client.AccountChangeWatchlistStatusAsync(MediaType.TVShow, IdHelper.BreakingBad, true).Sync();
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
// Test that the movie IS watchlisted
|
||||
accountState = _config.Client.GetTvShowAccountStateAsync(IdHelper.BreakingBad).Result;
|
||||
Assert.AreEqual(IdHelper.BreakingBad, accountState.Id);
|
||||
Assert.IsTrue(accountState.Watchlist);
|
||||
Assert.Equal(IdHelper.BreakingBad, accountState.Id);
|
||||
Assert.True(accountState.Watchlist);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowAccountStateRatingSet()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
@ -471,7 +459,7 @@ namespace TMDbLibTests
|
||||
// Remove the rating
|
||||
if (accountState.Rating.HasValue)
|
||||
{
|
||||
Assert.IsTrue(_config.Client.TvShowRemoveRatingAsync(IdHelper.BreakingBad).Result);
|
||||
Assert.True(_config.Client.TvShowRemoveRatingAsync(IdHelper.BreakingBad).Result);
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
@ -483,46 +471,46 @@ namespace TMDbLibTests
|
||||
// Test that the movie is NOT rated
|
||||
accountState = _config.Client.GetTvShowAccountStateAsync(IdHelper.BreakingBad).Result;
|
||||
|
||||
Assert.AreEqual(IdHelper.BreakingBad, accountState.Id);
|
||||
Assert.IsFalse(accountState.Rating.HasValue);
|
||||
Assert.Equal(IdHelper.BreakingBad, accountState.Id);
|
||||
Assert.False(accountState.Rating.HasValue);
|
||||
|
||||
// Rate the movie
|
||||
_config.Client.TvShowSetRatingAsync(IdHelper.BreakingBad, 5).Wait();
|
||||
_config.Client.TvShowSetRatingAsync(IdHelper.BreakingBad, 5).Sync();
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
// Test that the movie IS rated
|
||||
accountState = _config.Client.GetTvShowAccountStateAsync(IdHelper.BreakingBad).Result;
|
||||
Assert.AreEqual(IdHelper.BreakingBad, accountState.Id);
|
||||
Assert.IsTrue(accountState.Rating.HasValue);
|
||||
Assert.Equal(IdHelper.BreakingBad, accountState.Id);
|
||||
Assert.True(accountState.Rating.HasValue);
|
||||
|
||||
// Remove the rating
|
||||
Assert.IsTrue(_config.Client.TvShowRemoveRatingAsync(IdHelper.BreakingBad).Result);
|
||||
Assert.True(_config.Client.TvShowRemoveRatingAsync(IdHelper.BreakingBad).Result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowSetRatingBadRating()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
Assert.IsFalse(_config.Client.TvShowSetRatingAsync(IdHelper.BreakingBad, 7.1).Result);
|
||||
Assert.False(_config.Client.TvShowSetRatingAsync(IdHelper.BreakingBad, 7.1).Result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowSetRatingRatingOutOfBounds()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
Assert.IsFalse(_config.Client.TvShowSetRatingAsync(IdHelper.BreakingBad, 10.5).Result);
|
||||
Assert.False(_config.Client.TvShowSetRatingAsync(IdHelper.BreakingBad, 10.5).Result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowSetRatingRatingLowerBoundsTest()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
Assert.IsFalse(_config.Client.TvShowSetRatingAsync(IdHelper.BreakingBad, 0).Result);
|
||||
Assert.False(_config.Client.TvShowSetRatingAsync(IdHelper.BreakingBad, 0).Result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowSetRatingUserSession()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
@ -531,7 +519,7 @@ namespace TMDbLibTests
|
||||
// Remove the rating
|
||||
if (accountState.Rating.HasValue)
|
||||
{
|
||||
Assert.IsTrue(_config.Client.TvShowRemoveRatingAsync(IdHelper.BreakingBad).Result);
|
||||
Assert.True(_config.Client.TvShowRemoveRatingAsync(IdHelper.BreakingBad).Result);
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
@ -540,54 +528,54 @@ namespace TMDbLibTests
|
||||
// Test that the episode is NOT rated
|
||||
accountState = _config.Client.GetTvShowAccountStateAsync(IdHelper.BreakingBad).Result;
|
||||
|
||||
Assert.AreEqual(IdHelper.BreakingBad, accountState.Id);
|
||||
Assert.IsFalse(accountState.Rating.HasValue);
|
||||
Assert.Equal(IdHelper.BreakingBad, accountState.Id);
|
||||
Assert.False(accountState.Rating.HasValue);
|
||||
|
||||
// Rate the episode
|
||||
_config.Client.TvShowSetRatingAsync(IdHelper.BreakingBad, 5).Wait();
|
||||
_config.Client.TvShowSetRatingAsync(IdHelper.BreakingBad, 5).Sync();
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
// Test that the episode IS rated
|
||||
accountState = _config.Client.GetTvShowAccountStateAsync(IdHelper.BreakingBad).Result;
|
||||
Assert.AreEqual(IdHelper.BreakingBad, accountState.Id);
|
||||
Assert.IsTrue(accountState.Rating.HasValue);
|
||||
Assert.Equal(IdHelper.BreakingBad, accountState.Id);
|
||||
Assert.True(accountState.Rating.HasValue);
|
||||
|
||||
// Remove the rating
|
||||
Assert.IsTrue(_config.Client.TvShowRemoveRatingAsync(IdHelper.BreakingBad).Result);
|
||||
Assert.True(_config.Client.TvShowRemoveRatingAsync(IdHelper.BreakingBad).Result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void TestTvShowSetRatingGuestSession()
|
||||
{
|
||||
// There is no way to validate the change besides the success return of the api call since the guest session doesn't have access to anything else
|
||||
_config.Client.SetSessionInformation(_config.GuestTestSessionId, SessionType.GuestSession);
|
||||
|
||||
// Try changing the rating
|
||||
Assert.IsTrue(_config.Client.TvShowSetRatingAsync(IdHelper.BreakingBad, 7.5).Result);
|
||||
Assert.True(_config.Client.TvShowSetRatingAsync(IdHelper.BreakingBad, 7.5).Result);
|
||||
|
||||
// Try changing it back to the previous rating
|
||||
Assert.IsTrue(_config.Client.TvShowSetRatingAsync(IdHelper.BreakingBad, 8).Result);
|
||||
Assert.True(_config.Client.TvShowSetRatingAsync(IdHelper.BreakingBad, 8).Result);
|
||||
}
|
||||
|
||||
//[TestMethod]
|
||||
//[Fact]
|
||||
//public void TestMoviesLanguage()
|
||||
//{
|
||||
// Movie movie = _config.Client.GetMovieAsync(AGoodDayToDieHard);
|
||||
// Movie movieItalian = _config.Client.GetMovieAsync(AGoodDayToDieHard, "it");
|
||||
|
||||
// Assert.IsNotNull(movie);
|
||||
// Assert.IsNotNull(movieItalian);
|
||||
// Assert.NotNull(movie);
|
||||
// Assert.NotNull(movieItalian);
|
||||
|
||||
// Assert.AreEqual("A Good Day to Die Hard", movie.Title);
|
||||
// Assert.AreNotEqual(movie.Title, movieItalian.Title);
|
||||
// Assert.Equal("A Good Day to Die Hard", movie.Title);
|
||||
// Assert.NotEqual(movie.Title, movieItalian.Title);
|
||||
|
||||
// // Test all extras, ensure none of them exist
|
||||
// foreach (Func<Movie, object> selector in _methods.Values)
|
||||
// {
|
||||
// Assert.IsNull(selector(movie));
|
||||
// Assert.IsNull(selector(movieItalian));
|
||||
// Assert.Null(selector(movie));
|
||||
// Assert.Null(selector(movieItalian));
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
12
TMDbLibTests/Exceptions/Class.cs
Normal file
12
TMDbLibTests/Exceptions/Class.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace TMDbLibTests.Exceptions
|
||||
{
|
||||
public class ConfigurationErrorsException : Exception
|
||||
{
|
||||
public ConfigurationErrorsException(string message) : base(message)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
17
TMDbLibTests/Helpers/AsyncHelper.cs
Normal file
17
TMDbLibTests/Helpers/AsyncHelper.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TMDbLibTests.Helpers
|
||||
{
|
||||
public static class AsyncHelper
|
||||
{
|
||||
public static void Sync(this Task task)
|
||||
{
|
||||
task.GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static T Sync<T>(this Task<T> task)
|
||||
{
|
||||
return task.GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using TMDbLib.Objects.General;
|
||||
using Xunit;
|
||||
|
||||
namespace TMDbLibTests.Helpers
|
||||
{
|
||||
@ -10,12 +10,12 @@ namespace TMDbLibTests.Helpers
|
||||
{
|
||||
public static bool InternetUriExists(Uri uri)
|
||||
{
|
||||
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(uri);
|
||||
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri);
|
||||
req.Method = "HEAD";
|
||||
|
||||
try
|
||||
{
|
||||
using (req.GetResponse())
|
||||
using (req.GetResponseAsync().Sync())
|
||||
{
|
||||
// It exists
|
||||
return true;
|
||||
@ -37,28 +37,27 @@ namespace TMDbLibTests.Helpers
|
||||
// Check page 1
|
||||
SearchContainer<T> results = getter(1);
|
||||
|
||||
Assert.IsNotNull(results);
|
||||
Assert.IsNotNull(results.Results);
|
||||
Assert.AreEqual(1, results.Page);
|
||||
Assert.IsTrue(results.Results.Count > 0);
|
||||
Assert.IsTrue(results.TotalResults > 0);
|
||||
Assert.IsTrue(results.TotalPages > 0);
|
||||
Assert.NotNull(results);
|
||||
Assert.NotNull(results.Results);
|
||||
Assert.Equal(1, results.Page);
|
||||
Assert.True(results.Results.Count > 0);
|
||||
Assert.True(results.TotalResults > 0);
|
||||
Assert.True(results.TotalPages > 0);
|
||||
|
||||
// Check page 2
|
||||
SearchContainer<T> results2 = getter(2);
|
||||
|
||||
Assert.IsNotNull(results2);
|
||||
Assert.IsNotNull(results2.Results);
|
||||
Assert.AreEqual(2, results2.Page);
|
||||
Assert.NotNull(results2);
|
||||
Assert.NotNull(results2.Results);
|
||||
Assert.Equal(2, results2.Page);
|
||||
// The page counts often don't match due to caching on the api
|
||||
//Assert.AreEqual(results.TotalResults, results2.TotalResults);
|
||||
//Assert.AreEqual(results.TotalPages, results2.TotalPages);
|
||||
|
||||
if (results.Results.Count == results.TotalResults)
|
||||
Assert.AreEqual(0, results2.Results.Count);
|
||||
Assert.Equal(0, results2.Results.Count);
|
||||
else
|
||||
Assert.AreNotEqual(0, results2.Results.Count);
|
||||
|
||||
Assert.NotEqual(0, results2.Results.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMDbLib.Objects.General;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using TMDbLib.Objects.People;
|
||||
using Xunit;
|
||||
|
||||
namespace TMDbLibTests.Helpers
|
||||
{
|
||||
@ -14,7 +14,7 @@ namespace TMDbLibTests.Helpers
|
||||
|
||||
public static void TestImages(TestConfig config, ProfileImages images)
|
||||
{
|
||||
Assert.IsTrue(images.Profiles.Count > 0);
|
||||
Assert.True(images.Profiles.Count > 0);
|
||||
|
||||
string profileSize = config.Client.Config.Images.ProfileSizes.First();
|
||||
|
||||
@ -23,8 +23,8 @@ namespace TMDbLibTests.Helpers
|
||||
|
||||
public static void TestImages(TestConfig config, Images images)
|
||||
{
|
||||
Assert.IsTrue(images.Backdrops.Count > 0);
|
||||
Assert.IsTrue(images.Posters.Count > 0);
|
||||
Assert.True(images.Backdrops.Count > 0);
|
||||
Assert.True(images.Posters.Count > 0);
|
||||
|
||||
string backdropSize = config.Client.Config.Images.BackdropSizes.First();
|
||||
string posterSize = config.Client.Config.Images.PosterSizes.First();
|
||||
@ -41,8 +41,8 @@ namespace TMDbLibTests.Helpers
|
||||
Uri url = config.Client.GetImageUrl(posterSize, imageData);
|
||||
Uri urlSecure = config.Client.GetImageUrl(posterSize, imageData, true);
|
||||
|
||||
Assert.IsTrue(TestHelpers.InternetUriExists(url));
|
||||
Assert.IsTrue(TestHelpers.InternetUriExists(urlSecure));
|
||||
Assert.True(TestHelpers.InternetUriExists(url));
|
||||
Assert.True(TestHelpers.InternetUriExists(urlSecure));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System.Reflection;
|
||||
using Xunit;
|
||||
|
||||
namespace TMDbLibTests.Helpers
|
||||
{
|
||||
@ -9,7 +10,7 @@ namespace TMDbLibTests.Helpers
|
||||
{
|
||||
public static void TestGetExclusive<T, TId, TResult>(Dictionary<T, Func<TResult, object>> methodSelectors, Func<TId, T, TResult> getterMethod, TId id) where T : struct
|
||||
{
|
||||
Assert.IsTrue(typeof(T).IsEnum);
|
||||
Assert.True(typeof(T).GetTypeInfo().IsEnum);
|
||||
|
||||
// Test each method
|
||||
foreach (T method in methodSelectors.Keys)
|
||||
@ -18,22 +19,22 @@ namespace TMDbLibTests.Helpers
|
||||
TResult item = getterMethod(id, method);
|
||||
|
||||
// Ensure we have the piece we're looking for
|
||||
Assert.IsNotNull(methodSelectors[method](item));
|
||||
Assert.NotNull(methodSelectors[method](item));
|
||||
|
||||
// .. And none of the others
|
||||
foreach (T nonExpectedMethod in methodSelectors.Keys.Except(new[] { method }))
|
||||
Assert.IsNull(methodSelectors[nonExpectedMethod](item));
|
||||
Assert.Null(methodSelectors[nonExpectedMethod](item));
|
||||
}
|
||||
}
|
||||
|
||||
public static void TestAllNotNull<T, TResult>(Dictionary<T, Func<TResult, object>> methodSelectors, TResult item) where T : struct
|
||||
{
|
||||
Assert.IsTrue(typeof(T).IsEnum);
|
||||
Assert.True(typeof(T).GetTypeInfo().IsEnum);
|
||||
|
||||
// Ensure we have all the pieces
|
||||
foreach (T method in methodSelectors.Keys)
|
||||
{
|
||||
Assert.IsNotNull(methodSelectors[method](item), "Tested item was missing " + method);
|
||||
Assert.NotNull(methodSelectors[method](item));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Xunit;
|
||||
|
||||
namespace TMDbLibTests.JsonHelpers
|
||||
{
|
||||
public class TestBase
|
||||
public class TestBase : IDisposable
|
||||
{
|
||||
private static readonly Regex NormalizeRegex = new Regex(@"\[[\d]+\]", RegexOptions.Compiled);
|
||||
private readonly List<ErrorEventArgs> _errors = new List<ErrorEventArgs>();
|
||||
@ -23,11 +24,7 @@ namespace TMDbLibTests.JsonHelpers
|
||||
/// </summary>
|
||||
protected bool IgnoreMissingJson = false;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public virtual void Initiator()
|
||||
public TestBase()
|
||||
{
|
||||
_errors.Clear();
|
||||
|
||||
@ -35,9 +32,9 @@ namespace TMDbLibTests.JsonHelpers
|
||||
{
|
||||
JsonSerializerSettings sett = new JsonSerializerSettings();
|
||||
|
||||
sett.MissingMemberHandling = MissingMemberHandling.Error;
|
||||
sett.ContractResolver = new FailingContractResolver();
|
||||
sett.Error = Error;
|
||||
//sett.MissingMemberHandling = MissingMemberHandling.Error;
|
||||
//sett.ContractResolver = new FailingContractResolver();
|
||||
//sett.Error = Error;
|
||||
|
||||
return sett;
|
||||
};
|
||||
@ -49,11 +46,7 @@ namespace TMDbLibTests.JsonHelpers
|
||||
errorEventArgs.ErrorContext.Handled = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestCleanup]
|
||||
public virtual void Closer()
|
||||
public void Dispose()
|
||||
{
|
||||
if (_errors.Any())
|
||||
{
|
||||
@ -114,7 +107,7 @@ namespace TMDbLibTests.JsonHelpers
|
||||
}
|
||||
|
||||
if (missingFieldInCSharp.Any() || missingPropertyInJson.Any() || other.Any())
|
||||
Assert.Inconclusive(sb.ToString());
|
||||
throw new Exception(sb.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,35 +1,19 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("TMDbLibTests")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("TMDbLibTests")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("19b1bc10-9af5-4e3f-876f-a91b9cbad5bb")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: Guid("228615eb-bfa3-44a7-8648-a7ea48470777")]
|
||||
|
@ -1,132 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{00AB08ED-9484-4AAE-9C8C-D19E40325E16}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TMDbLibTests</RootNamespace>
|
||||
<AssemblyName>TMDbLibTests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
|
||||
<IsCodedUITest>False</IsCodedUITest>
|
||||
<TestProjectType>UnitTest</TestProjectType>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="TMDbLib, Version=0.9.0.3, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\TMDbLib\bin\Debug\net45\TMDbLib.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<Choose>
|
||||
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
||||
</ItemGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
|
||||
</ItemGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
<ItemGroup>
|
||||
<Compile Include="ClientCertificationsTests.cs" />
|
||||
<Compile Include="ClientCreditTests.cs" />
|
||||
<Compile Include="ClientFindTests.cs" />
|
||||
<Compile Include="ClientAccountTests.cs" />
|
||||
<Compile Include="ClientAuthenticationTests.cs" />
|
||||
<Compile Include="ClientGuestSessionTests.cs" />
|
||||
<Compile Include="ClientNetworkTests.cs" />
|
||||
<Compile Include="ClientDiscoverTests.cs" />
|
||||
<Compile Include="ClientReviewTests.cs" />
|
||||
<Compile Include="ClientTimezonesTests.cs" />
|
||||
<Compile Include="ClientTvEpisodeTests.cs" />
|
||||
<Compile Include="ClientTvSeasonTests.cs" />
|
||||
<Compile Include="ClientTvShowTests.cs" />
|
||||
<Compile Include="ClientMovieTests.cs" />
|
||||
<Compile Include="ClientKeywordTests.cs" />
|
||||
<Compile Include="ClientCompanyTests.cs" />
|
||||
<Compile Include="ClientListsTests.cs" />
|
||||
<Compile Include="ClientPersonTests.cs" />
|
||||
<Compile Include="ClientChangesTests.cs" />
|
||||
<Compile Include="ClientCollectionTests.cs" />
|
||||
<Compile Include="ClientSearchTests.cs" />
|
||||
<Compile Include="ClientJobTests.cs" />
|
||||
<Compile Include="JsonHelpers\FailingContractResolver.cs" />
|
||||
<Compile Include="Helpers\IdHelper.cs" />
|
||||
<Compile Include="Helpers\TestImagesHelpers.cs" />
|
||||
<Compile Include="Helpers\TestHelpers.cs" />
|
||||
<Compile Include="JsonHelpers\TestBase.cs" />
|
||||
<Compile Include="TestClasses\EnumTestEnum.cs" />
|
||||
<Compile Include="TestConfig.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ClientTests.cs" />
|
||||
<Compile Include="ClientGenreTests.cs" />
|
||||
<Compile Include="TestClasses\EnumTestStruct.cs" />
|
||||
<Compile Include="Helpers\TestMethodsHelper.cs" />
|
||||
<Compile Include="UtilsTest.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Choose>
|
||||
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
</When>
|
||||
</Choose>
|
||||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
22
TMDbLibTests/TMDbLibTests.xproj
Normal file
22
TMDbLibTests/TMDbLibTests.xproj
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>228615eb-bfa3-44a7-8648-a7ea48470777</ProjectGuid>
|
||||
<RootNamespace>TMDbLibTests</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
@ -1,4 +1,4 @@
|
||||
using System.Configuration;
|
||||
using TMDbLibTests.Exceptions;
|
||||
using TMDbLib.Client;
|
||||
|
||||
namespace TMDbLibTests
|
||||
|
@ -1,41 +1,37 @@
|
||||
using System;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Xunit;
|
||||
using TMDbLib.Utilities;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
using TMDbLibTests.TestClasses;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class UtilsTest : TestBase
|
||||
{
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentException), AllowDerivedTypes = false)]
|
||||
[Fact]
|
||||
public void EnumDescriptionNonEnumTest()
|
||||
{
|
||||
EnumTestStruct strct = new EnumTestStruct();
|
||||
strct.GetDescription();
|
||||
|
||||
// Should always throw exception
|
||||
Assert.Fail();
|
||||
Assert.Throws<ArgumentException>(() => strct.GetDescription());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void EnumDescriptionNonDescriptionTest()
|
||||
{
|
||||
EnumTestEnum enm = EnumTestEnum.A;
|
||||
string s = enm.GetDescription();
|
||||
|
||||
Assert.AreEqual("A", s);
|
||||
Assert.Equal("A", s);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void EnumDescriptionTest()
|
||||
{
|
||||
EnumTestEnum enm = EnumTestEnum.B;
|
||||
string s = enm.GetDescription();
|
||||
|
||||
Assert.AreEqual("B-Description", s);
|
||||
Assert.Equal("B-Description", s);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net452" />
|
||||
</packages>
|
21
TMDbLibTests/project.json
Normal file
21
TMDbLibTests/project.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"version": "1.0.0-*",
|
||||
"testRunner": "xunit",
|
||||
|
||||
"dependencies": {
|
||||
"xunit": "2.2.0-beta2-build3300",
|
||||
"dotnet-test-xunit": "2.2.0-preview2-build1029",
|
||||
"TMDbLib": "0.9.1.1-alpha"
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"type": "platform",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
7497
TMDbLibTests/project.lock.json
Normal file
7497
TMDbLibTests/project.lock.json
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user