Move ID's for tests into central class

This commit is contained in:
Michael Bisbjerg 2015-11-18 23:18:52 +01:00
parent 9115aad73e
commit 774106557d
17 changed files with 334 additions and 327 deletions

View File

@ -16,8 +16,6 @@ namespace TMDbLibTests
public class ClientAccountTests
{
private TestConfig _config;
private const int Terminator = 218;
private const int DoctorWho = 121;
/// <summary>
/// Run once, on every test
@ -255,20 +253,20 @@ namespace TMDbLibTests
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
// Ensure that the test movie is not marked as favorite before we start the test
if (DoesFavoriteListContainSpecificTvShow(DoctorWho))
Assert.Fail("Test tv show '{0}' was already marked as favorite. Unable to perform test correctly", DoctorWho);
if (DoesFavoriteListContainSpecificTvShow(IdHelper.DoctorWho))
Assert.Fail("Test tv show '{0}' was already marked as favorite. Unable to perform test correctly", IdHelper.DoctorWho);
// Try to mark is as a favorite
Assert.IsTrue(_config.Client.AccountChangeFavoriteStatus(MediaType.TVShow, DoctorWho, true).Result);
Assert.IsTrue(_config.Client.AccountChangeFavoriteStatus(MediaType.TVShow, IdHelper.DoctorWho, true).Result);
// Check if it worked
Assert.IsTrue(DoesFavoriteListContainSpecificTvShow(DoctorWho));
Assert.IsTrue(DoesFavoriteListContainSpecificTvShow(IdHelper.DoctorWho));
// Try to un-mark is as a favorite
Assert.IsTrue(_config.Client.AccountChangeFavoriteStatus(MediaType.TVShow, DoctorWho, false).Result);
Assert.IsTrue(_config.Client.AccountChangeFavoriteStatus(MediaType.TVShow, IdHelper.DoctorWho, false).Result);
// Check if it worked
Assert.IsFalse(DoesFavoriteListContainSpecificTvShow(DoctorWho));
Assert.IsFalse(DoesFavoriteListContainSpecificTvShow(IdHelper.DoctorWho));
}
[TestMethod]
@ -277,20 +275,20 @@ namespace TMDbLibTests
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
// Ensure that the test movie is not marked as favorite before we start the test
if (DoesFavoriteListContainSpecificMovie(Terminator))
Assert.Fail("Test movie '{0}' was already marked as favorite. Unable to perform test correctly", Terminator);
if (DoesFavoriteListContainSpecificMovie(IdHelper.Terminator))
Assert.Fail("Test movie '{0}' was already marked as favorite. Unable to perform test correctly", IdHelper.Terminator);
// Try to mark is as a favorite
Assert.IsTrue(_config.Client.AccountChangeFavoriteStatus(MediaType.Movie, Terminator, true).Result);
Assert.IsTrue(_config.Client.AccountChangeFavoriteStatus(MediaType.Movie, IdHelper.Terminator, true).Result);
// Check if it worked
Assert.IsTrue(DoesFavoriteListContainSpecificMovie(Terminator));
Assert.IsTrue(DoesFavoriteListContainSpecificMovie(IdHelper.Terminator));
// Try to un-mark is as a favorite
Assert.IsTrue(_config.Client.AccountChangeFavoriteStatus(MediaType.Movie, Terminator, false).Result);
Assert.IsTrue(_config.Client.AccountChangeFavoriteStatus(MediaType.Movie, IdHelper.Terminator, false).Result);
// Check if it worked
Assert.IsFalse(DoesFavoriteListContainSpecificMovie(Terminator));
Assert.IsFalse(DoesFavoriteListContainSpecificMovie(IdHelper.Terminator));
}
[TestMethod]
@ -299,20 +297,20 @@ namespace TMDbLibTests
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
// Ensure that the test movie is not marked as favorite before we start the test
if (DoesWatchListContainSpecificTvShow(DoctorWho))
Assert.Fail("Test tv show '{0}' was already on watchlist. Unable to perform test correctly", DoctorWho);
if (DoesWatchListContainSpecificTvShow(IdHelper.DoctorWho))
Assert.Fail("Test tv show '{0}' was already on watchlist. Unable to perform test correctly", IdHelper.DoctorWho);
// Try to add an item to the watchlist
Assert.IsTrue(_config.Client.AccountChangeWatchlistStatus(MediaType.TVShow, DoctorWho, true).Result);
Assert.IsTrue(_config.Client.AccountChangeWatchlistStatus(MediaType.TVShow, IdHelper.DoctorWho, true).Result);
// Check if it worked
Assert.IsTrue(DoesWatchListContainSpecificTvShow(DoctorWho));
Assert.IsTrue(DoesWatchListContainSpecificTvShow(IdHelper.DoctorWho));
// Try to remove item from watchlist
Assert.IsTrue(_config.Client.AccountChangeWatchlistStatus(MediaType.TVShow, DoctorWho, false).Result);
Assert.IsTrue(_config.Client.AccountChangeWatchlistStatus(MediaType.TVShow, IdHelper.DoctorWho, false).Result);
// Check if it worked
Assert.IsFalse(DoesWatchListContainSpecificTvShow(DoctorWho));
Assert.IsFalse(DoesWatchListContainSpecificTvShow(IdHelper.DoctorWho));
}
[TestMethod]
@ -321,20 +319,20 @@ namespace TMDbLibTests
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
// Ensure that the test movie is not marked as favorite before we start the test
if (DoesWatchListContainSpecificMovie(Terminator))
Assert.Fail("Test movie '{0}' was already on watchlist. Unable to perform test correctly", Terminator);
if (DoesWatchListContainSpecificMovie(IdHelper.Terminator))
Assert.Fail("Test movie '{0}' was already on watchlist. Unable to perform test correctly", IdHelper.Terminator);
// Try to add an item to the watchlist
Assert.IsTrue(_config.Client.AccountChangeWatchlistStatus(MediaType.Movie, Terminator, true).Result);
Assert.IsTrue(_config.Client.AccountChangeWatchlistStatus(MediaType.Movie, IdHelper.Terminator, true).Result);
// Check if it worked
Assert.IsTrue(DoesWatchListContainSpecificMovie(Terminator));
Assert.IsTrue(DoesWatchListContainSpecificMovie(IdHelper.Terminator));
// Try to remove item from watchlist
Assert.IsTrue(_config.Client.AccountChangeWatchlistStatus(MediaType.Movie, Terminator, false).Result);
Assert.IsTrue(_config.Client.AccountChangeWatchlistStatus(MediaType.Movie, IdHelper.Terminator, false).Result);
// Check if it worked
Assert.IsFalse(DoesWatchListContainSpecificMovie(Terminator));
Assert.IsFalse(DoesWatchListContainSpecificMovie(IdHelper.Terminator));
}
private bool DoesFavoriteListContainSpecificTvShow(int tvId)

View File

@ -11,7 +11,6 @@ namespace TMDbLibTests
[TestClass]
public class ClientCollectionTests
{
private const int JamesBondCollection = 645;
private static Dictionary<CollectionMethods, Func<Collection, object>> _methods;
private TestConfig _config;
@ -37,7 +36,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestCollectionsExtrasNone()
{
Collection collection = _config.Client.GetCollection(JamesBondCollection).Result;
Collection collection = _config.Client.GetCollection(IdHelper.JamesBondCollection).Result;
// TODO: Test all properties
Assert.IsNotNull(collection);
@ -55,14 +54,14 @@ namespace TMDbLibTests
[TestMethod]
public void TestCollectionsExtrasExclusive()
{
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetCollection(id, extras).Result, JamesBondCollection);
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetCollection(id, extras).Result, IdHelper.JamesBondCollection);
}
[TestMethod]
public void TestCollectionsExtrasAll()
{
CollectionMethods combinedEnum = _methods.Keys.Aggregate((methods, movieMethods) => methods | movieMethods);
Collection item = _config.Client.GetCollection(JamesBondCollection, combinedEnum).Result;
Collection item = _config.Client.GetCollection(IdHelper.JamesBondCollection, combinedEnum).Result;
TestMethodsHelper.TestAllNotNull(_methods, item);
}
@ -74,9 +73,9 @@ namespace TMDbLibTests
_config.Client.GetConfig();
// Test image url generator
ImagesWithId images = _config.Client.GetCollectionImages(JamesBondCollection).Result;
ImagesWithId images = _config.Client.GetCollectionImages(IdHelper.JamesBondCollection).Result;
Assert.AreEqual(JamesBondCollection, images.Id);
Assert.AreEqual(IdHelper.JamesBondCollection, images.Id);
TestImagesHelpers.TestImages(_config, images);
}
}

View File

@ -11,9 +11,6 @@ namespace TMDbLibTests
[TestClass]
public class ClientCompanyTests
{
private const int TwentiethCenturyFox = 25;
private const int ColumbiaPictures = 5;
private static Dictionary<CompanyMethods, Func<Company, object>> _methods;
private TestConfig _config;
@ -39,7 +36,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestCompaniesExtrasNone()
{
Company company = _config.Client.GetCompany(TwentiethCenturyFox).Result;
Company company = _config.Client.GetCompany(IdHelper.TwentiethCenturyFox).Result;
Assert.IsNotNull(company);
@ -56,14 +53,14 @@ namespace TMDbLibTests
[TestMethod]
public void TestCompaniesExtrasExclusive()
{
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetCompany(id, extras).Result, TwentiethCenturyFox);
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetCompany(id, extras).Result, IdHelper.TwentiethCenturyFox);
}
[TestMethod]
public void TestCompaniesExtrasAll()
{
CompanyMethods combinedEnum = _methods.Keys.Aggregate((methods, movieMethods) => methods | movieMethods);
Company item = _config.Client.GetCompany(TwentiethCenturyFox, combinedEnum).Result;
Company item = _config.Client.GetCompany(IdHelper.TwentiethCenturyFox, combinedEnum).Result;
TestMethodsHelper.TestAllNotNull(_methods, item);
}
@ -72,9 +69,9 @@ namespace TMDbLibTests
public void TestCompaniesGetters()
{
//GetCompanyMovies(int id, string language, int page = -1)
SearchContainerWithId<MovieResult> resp = _config.Client.GetCompanyMovies(TwentiethCenturyFox).Result;
SearchContainerWithId<MovieResult> respPage2 = _config.Client.GetCompanyMovies(TwentiethCenturyFox, 2).Result;
SearchContainerWithId<MovieResult> respItalian = _config.Client.GetCompanyMovies(TwentiethCenturyFox, "it").Result;
SearchContainerWithId<MovieResult> resp = _config.Client.GetCompanyMovies(IdHelper.TwentiethCenturyFox).Result;
SearchContainerWithId<MovieResult> respPage2 = _config.Client.GetCompanyMovies(IdHelper.TwentiethCenturyFox, 2).Result;
SearchContainerWithId<MovieResult> respItalian = _config.Client.GetCompanyMovies(IdHelper.TwentiethCenturyFox, "it").Result;
Assert.IsNotNull(resp);
Assert.IsNotNull(respPage2);
@ -103,7 +100,7 @@ namespace TMDbLibTests
_config.Client.GetConfig();
// Test image url generator
Company company = _config.Client.GetCompany(TwentiethCenturyFox).Result;
Company company = _config.Client.GetCompany(IdHelper.TwentiethCenturyFox).Result;
Uri url = _config.Client.GetImageUrl("original", company.LogoPath);
Uri urlSecure = _config.Client.GetImageUrl("original", company.LogoPath, true);
@ -115,11 +112,11 @@ namespace TMDbLibTests
[TestMethod]
public void TestCompaniesFull()
{
Company company = _config.Client.GetCompany(ColumbiaPictures).Result;
Company company = _config.Client.GetCompany(IdHelper.ColumbiaPictures).Result;
Assert.IsNotNull(company);
Assert.AreEqual(ColumbiaPictures, company.Id);
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);

View File

@ -9,9 +9,6 @@ namespace TMDbLibTests
[TestClass]
public class ClientCreditTests
{
const string BruceWillisMiamiVice = "525719bb760ee3776a1835d3";
const string HughLaurieHouse = "5256ccf519c2956ff607ca00";
private TestConfig _config;
/// <summary>
@ -26,14 +23,14 @@ namespace TMDbLibTests
[TestMethod]
public void TestGetCreditBase()
{
Credit result = _config.Client.GetCredits(BruceWillisMiamiVice).Result;
Credit result = _config.Client.GetCredits(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(BruceWillisMiamiVice, result.Id);
Assert.AreEqual(IdHelper.BruceWillisMiamiVice, result.Id);
Assert.IsNotNull(result.Person);
Assert.AreEqual("Bruce Willis", result.Person.Name);
@ -49,7 +46,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestGetCreditEpisode()
{
Credit result = _config.Client.GetCredits(BruceWillisMiamiVice).Result;
Credit result = _config.Client.GetCredits(IdHelper.BruceWillisMiamiVice).Result;
Assert.IsNotNull(result);
Assert.IsNotNull(result.Media);
@ -69,7 +66,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestGetCreditSeasons()
{
Credit result = _config.Client.GetCredits(HughLaurieHouse).Result;
Credit result = _config.Client.GetCredits(IdHelper.HughLaurieHouse).Result;
Assert.IsNotNull(result);
Assert.IsNotNull(result.Media);

View File

@ -1,5 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TMDbLib.Objects.Find;
using TMDbLibTests.Helpers;
namespace TMDbLibTests
{
@ -7,14 +8,6 @@ namespace TMDbLibTests
public class ClientFindTests
{
private TestConfig _config;
private const int tmdbTerminatorId = 218;
private const string imdbTerminatorId = "tt0088247";
private const int tmdbBreakingBadId = 1396;
private const string tvdbBreakingBadId = "81189";
private const string imdbBreakingBadId = "tt0903747";
private const string tvRageBreakingBadId = "18164";
private const string freebaseBreakingBadId = "en/breaking_bad";
private const string freebaseMidBreakingBadId = "m/03d34x8";
/// <summary>
/// Run once, on every test
@ -28,49 +21,49 @@ namespace TMDbLibTests
[TestMethod]
public void TestFindImdbMovie()
{
var result = _config.Client.Find(FindExternalSource.Imdb, imdbTerminatorId);
var result = _config.Client.Find(FindExternalSource.Imdb, IdHelper.imdbTerminatorId);
Assert.AreEqual(1, result.Result.MovieResults.Count);
Assert.AreEqual(tmdbTerminatorId, result.Result.MovieResults[0].Id);
Assert.AreEqual(IdHelper.tmdbTerminatorId, result.Result.MovieResults[0].Id);
}
[TestMethod]
public void TestFindTvdbTvShow()
{
var result = _config.Client.Find(FindExternalSource.TvDb, tvdbBreakingBadId);
var result = _config.Client.Find(FindExternalSource.TvDb, IdHelper.TvdbBreakingBadId);
Assert.AreEqual(1, result.Result.TvResults.Count);
Assert.AreEqual(tmdbBreakingBadId, result.Result.TvResults[0].Id);
Assert.AreEqual(IdHelper.TmdbBreakingBadId, result.Result.TvResults[0].Id);
}
[TestMethod]
public void TestFindImdbTvShow()
{
var result = _config.Client.Find(FindExternalSource.Imdb, imdbBreakingBadId);
var result = _config.Client.Find(FindExternalSource.Imdb, IdHelper.ImdbBreakingBadId);
Assert.AreEqual(1, result.Result.TvResults.Count);
Assert.AreEqual(tmdbBreakingBadId, result.Result.TvResults[0].Id);
Assert.AreEqual(IdHelper.TmdbBreakingBadId, result.Result.TvResults[0].Id);
}
[TestMethod]
public void TestFindTvRageTvShow()
{
var result = _config.Client.Find(FindExternalSource.TvRage, tvRageBreakingBadId);
var result = _config.Client.Find(FindExternalSource.TvRage, IdHelper.TvRageBreakingBadId);
Assert.AreEqual(1, result.Result.TvResults.Count);
Assert.AreEqual(tmdbBreakingBadId, result.Result.TvResults[0].Id);
Assert.AreEqual(IdHelper.TmdbBreakingBadId, result.Result.TvResults[0].Id);
}
[TestMethod]
public void TestFindFreebaseTvShow()
{
var result = _config.Client.Find(FindExternalSource.FreeBaseId, freebaseBreakingBadId);
var result = _config.Client.Find(FindExternalSource.FreeBaseId, IdHelper.FreebaseBreakingBadId);
Assert.AreEqual(1, result.Result.TvResults.Count);
Assert.AreEqual(tmdbBreakingBadId, result.Result.TvResults[0].Id);
Assert.AreEqual(IdHelper.TmdbBreakingBadId, result.Result.TvResults[0].Id);
}
[TestMethod]
public void TestFindFreebaseMidTvShow()
{
var result = _config.Client.Find(FindExternalSource.FreeBaseMid, freebaseMidBreakingBadId);
var result = _config.Client.Find(FindExternalSource.FreeBaseMid, IdHelper.FreebaseMidBreakingBadId);
Assert.AreEqual(1, result.Result.TvResults.Count);
Assert.AreEqual(tmdbBreakingBadId, result.Result.TvResults[0].Id);
Assert.AreEqual(IdHelper.TmdbBreakingBadId, result.Result.TvResults[0].Id);
}
}
}

View File

@ -13,11 +13,6 @@ namespace TMDbLibTests
[TestClass]
public class ClientGuestSessionTests
{
private const int Avatar = 19995;
private const int Terminator = 218;
private const int BigBangTheory = 1418;
private const int BreakingBad = 1396;
private TestConfig _config;
/// <summary>
@ -35,36 +30,36 @@ namespace TMDbLibTests
_config.Client.SetSessionInformation(_config.GuestTestSessionId, SessionType.GuestSession);
// Try changing the rating
Assert.IsTrue(_config.Client.TvEpisodeSetRating(BreakingBad, 1, 1, 7.5).Result);
Assert.IsTrue(_config.Client.TvEpisodeSetRating(IdHelper.BreakingBad, 1, 1, 7.5).Result);
// Allow TMDb to cache our changes
Thread.Sleep(2000);
SearchContainer<TvEpisodeWithRating> ratings = _config.Client.GetGuestSessionRatedTvEpisodes().Result;
Assert.IsTrue(ratings.Results.Any(s => s.ShowId == BreakingBad && s.SeasonNumber == 1 && s.EpisodeNumber == 1));
Assert.AreEqual(7.5, ratings.Results.Single(s => s.ShowId == BreakingBad && s.SeasonNumber == 1 && s.EpisodeNumber == 1).Rating, float.Epsilon);
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);
// Try changing it back to the previous rating
Assert.IsTrue(_config.Client.TvEpisodeSetRating(BreakingBad, 1, 1, 8).Result);
Assert.IsTrue(_config.Client.TvEpisodeSetRating(IdHelper.BreakingBad, 1, 1, 8).Result);
// Allow TMDb to cache our changes
Thread.Sleep(2000);
ratings = _config.Client.GetGuestSessionRatedTvEpisodes().Result;
Assert.IsTrue(ratings.Results.Any(s => s.ShowId == BreakingBad && s.SeasonNumber == 1 && s.EpisodeNumber == 1));
Assert.AreEqual(8, ratings.Results.Single(s => s.ShowId == BreakingBad && s.SeasonNumber == 1 && s.EpisodeNumber == 1).Rating, float.Epsilon);
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);
// Try removing the rating
Assert.IsTrue(_config.Client.TvEpisodeRemoveRating(BreakingBad, 1, 1).Result);
Assert.IsTrue(_config.Client.TvEpisodeRemoveRating(IdHelper.BreakingBad, 1, 1).Result);
// Allow TMDb to cache our changes
Thread.Sleep(2000);
ratings = _config.Client.GetGuestSessionRatedTvEpisodes().Result;
Assert.IsFalse(ratings.Results.Any(s => s.ShowId == BreakingBad && s.SeasonNumber == 1 && s.EpisodeNumber == 1));
Assert.IsFalse(ratings.Results.Any(s => s.ShowId == IdHelper.BreakingBad && s.SeasonNumber == 1 && s.EpisodeNumber == 1));
}
[TestMethod]
@ -73,36 +68,36 @@ namespace TMDbLibTests
_config.Client.SetSessionInformation(_config.GuestTestSessionId, SessionType.GuestSession);
// Try changing the rating
Assert.IsTrue(_config.Client.TvShowSetRating(BreakingBad, 7.5).Result);
Assert.IsTrue(_config.Client.TvShowSetRating(IdHelper.BreakingBad, 7.5).Result);
// Allow TMDb to cache our changes
Thread.Sleep(2000);
SearchContainer<TvShowWithRating> ratings = _config.Client.GetGuestSessionRatedTv().Result;
Assert.IsTrue(ratings.Results.Any(s => s.Id == BreakingBad));
Assert.AreEqual(7.5, ratings.Results.Single(s => s.Id == BreakingBad).Rating, float.Epsilon);
Assert.IsTrue(ratings.Results.Any(s => s.Id == IdHelper.BreakingBad));
Assert.AreEqual(7.5, ratings.Results.Single(s => s.Id == IdHelper.BreakingBad).Rating, float.Epsilon);
// Try changing it back to the previous rating
Assert.IsTrue(_config.Client.TvShowSetRating(BreakingBad, 8).Result);
Assert.IsTrue(_config.Client.TvShowSetRating(IdHelper.BreakingBad, 8).Result);
// Allow TMDb to cache our changes
Thread.Sleep(2000);
ratings = _config.Client.GetGuestSessionRatedTv().Result;
Assert.IsTrue(ratings.Results.Any(s => s.Id == BreakingBad));
Assert.AreEqual(8, ratings.Results.Single(s => s.Id == BreakingBad).Rating, float.Epsilon);
Assert.IsTrue(ratings.Results.Any(s => s.Id == IdHelper.BreakingBad));
Assert.AreEqual(8, ratings.Results.Single(s => s.Id == IdHelper.BreakingBad).Rating, float.Epsilon);
// Try removing the rating
Assert.IsTrue(_config.Client.TvShowRemoveRating(BreakingBad).Result);
Assert.IsTrue(_config.Client.TvShowRemoveRating(IdHelper.BreakingBad).Result);
// Allow TMDb to cache our changes
Thread.Sleep(2000);
ratings = _config.Client.GetGuestSessionRatedTv().Result;
Assert.IsFalse(ratings.Results.Any(s => s.Id == BreakingBad));
Assert.IsFalse(ratings.Results.Any(s => s.Id == IdHelper.BreakingBad));
}
[TestMethod]
@ -111,36 +106,36 @@ namespace TMDbLibTests
_config.Client.SetSessionInformation(_config.GuestTestSessionId, SessionType.GuestSession);
// Try changing the rating
Assert.IsTrue(_config.Client.MovieSetRating(Avatar, 7.5).Result);
Assert.IsTrue(_config.Client.MovieSetRating(IdHelper.Avatar, 7.5).Result);
// Allow TMDb to cache our changes
Thread.Sleep(2000);
SearchContainer<MovieWithRating> ratings = _config.Client.GetGuestSessionRatedMovies().Result;
Assert.IsTrue(ratings.Results.Any(s => s.Id == Avatar));
Assert.AreEqual(7.5, ratings.Results.Single(s => s.Id == Avatar).Rating, float.Epsilon);
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);
// Try changing it back to the previous rating
Assert.IsTrue(_config.Client.MovieSetRating(Avatar, 8).Result);
Assert.IsTrue(_config.Client.MovieSetRating(IdHelper.Avatar, 8).Result);
// Allow TMDb to cache our changes
Thread.Sleep(2000);
ratings = _config.Client.GetGuestSessionRatedMovies().Result;
Assert.IsTrue(ratings.Results.Any(s => s.Id == Avatar));
Assert.AreEqual(8, ratings.Results.Single(s => s.Id == Avatar).Rating, float.Epsilon);
Assert.IsTrue(ratings.Results.Any(s => s.Id == IdHelper.Avatar));
Assert.AreEqual(8, ratings.Results.Single(s => s.Id == IdHelper.Avatar).Rating, float.Epsilon);
// Try removing the rating
Assert.IsTrue(_config.Client.MovieRemoveRating(Avatar).Result);
Assert.IsTrue(_config.Client.MovieRemoveRating(IdHelper.Avatar).Result);
// Allow TMDb to cache our changes
Thread.Sleep(2000);
ratings = _config.Client.GetGuestSessionRatedMovies().Result;
Assert.IsFalse(ratings.Results.Any(s => s.Id == Avatar));
Assert.IsFalse(ratings.Results.Any(s => s.Id == IdHelper.Avatar));
}
[TestMethod]
@ -149,7 +144,7 @@ namespace TMDbLibTests
_config.Client.SetSessionInformation(_config.GuestTestSessionId, SessionType.GuestSession);
// Ensure we have a rating
Assert.IsTrue(_config.Client.TvEpisodeSetRating(BigBangTheory, 1, 1, 7.5).Result);
Assert.IsTrue(_config.Client.TvEpisodeSetRating(IdHelper.BigBangTheory, 1, 1, 7.5).Result);
// Test paging
TestHelpers.SearchPages(i => _config.Client.GetGuestSessionRatedTvEpisodes(i).Result);
@ -167,7 +162,7 @@ namespace TMDbLibTests
_config.Client.SetSessionInformation(_config.GuestTestSessionId, SessionType.GuestSession);
// Ensure we have a rating
Assert.IsTrue(_config.Client.TvShowSetRating(BigBangTheory, 7.5).Result);
Assert.IsTrue(_config.Client.TvShowSetRating(IdHelper.BigBangTheory, 7.5).Result);
// Test paging
TestHelpers.SearchPages(i => _config.Client.GetGuestSessionRatedTv(i).Result);
@ -185,7 +180,7 @@ namespace TMDbLibTests
_config.Client.SetSessionInformation(_config.GuestTestSessionId, SessionType.GuestSession);
// Ensure we have a rating
Assert.IsTrue(_config.Client.MovieSetRating(Terminator, 7.5).Result);
Assert.IsTrue(_config.Client.MovieSetRating(IdHelper.Terminator, 7.5).Result);
// Test paging
TestHelpers.SearchPages(i => _config.Client.GetGuestSessionRatedMovies(i).Result);

View File

@ -2,13 +2,13 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TMDbLib.Objects.General;
using TMDbLib.Objects.Movies;
using TMDbLibTests.Helpers;
namespace TMDbLibTests
{
[TestClass]
public class ClientKeywordTests
{
private const int AGoodDayToDieHard = 47964;
private TestConfig _config;
/// <summary>
@ -23,7 +23,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestKeywordGet()
{
KeywordsContainer keywords = _config.Client.GetMovieKeywords(AGoodDayToDieHard).Result;
KeywordsContainer keywords = _config.Client.GetMovieKeywords(IdHelper.AGoodDayToDieHard).Result;
Assert.IsNotNull(keywords);
Assert.IsNotNull(keywords.Keywords);
@ -44,7 +44,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestKeywordMovies()
{
KeywordsContainer keywords = _config.Client.GetMovieKeywords(AGoodDayToDieHard).Result;
KeywordsContainer keywords = _config.Client.GetMovieKeywords(IdHelper.AGoodDayToDieHard).Result;
Assert.IsNotNull(keywords);
Assert.IsNotNull(keywords.Keywords);

View File

@ -1,21 +1,19 @@
using System.Linq;
using System;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TMDbLib.Objects.Authentication;
using TMDbLib.Objects.General;
using TMDbLib.Objects.Lists;
using TMDbLib.Objects.Movies;
using TMDbLibTests.Helpers;
namespace TMDbLibTests
{
[TestClass]
public class ClientListsTests
{
private const int Avatar = 19995;
private const int Terminator = 218;
private const int EvanAlmighty = 2698;
private const int MadMaxFuryRoad = 76341;
private const string TestListId = "528349d419c2954bd21ca0a8";
private TestConfig _config;
private const string TestListId = "528349d419c2954bd21ca0a8";
/// <summary>
/// Run once, on every test
@ -64,20 +62,20 @@ namespace TMDbLibTests
[TestMethod]
public void TestListIsMoviePresentFailure()
{
Assert.IsFalse(_config.Client.GetListIsMoviePresent(TestListId, Terminator).Result);
Assert.IsFalse(_config.Client.GetListIsMoviePresent(TestListId, IdHelper.Terminator).Result);
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
// Clear list
Assert.IsTrue(_config.Client.ListClear(TestListId).Result);
// Verify Avatar is not present
Assert.IsFalse(_config.Client.GetListIsMoviePresent(TestListId, Avatar).Result);
Assert.IsFalse(_config.Client.GetListIsMoviePresent(TestListId, IdHelper.Avatar).Result);
// Add Avatar
Assert.IsTrue(_config.Client.ListAddMovie(TestListId, Avatar).Result);
Assert.IsTrue(_config.Client.ListAddMovie(TestListId, IdHelper.Avatar).Result);
// Verify Avatar is present
Assert.IsTrue(_config.Client.GetListIsMoviePresent(TestListId, Avatar).Result);
Assert.IsTrue(_config.Client.GetListIsMoviePresent(TestListId, IdHelper.Avatar).Result);
}
[TestMethod]
@ -88,7 +86,7 @@ namespace TMDbLibTests
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
string newListId = _config.Client.ListCreate(listName).Result;
Assert.IsFalse(string.IsNullOrWhiteSpace(newListId));
Assert.IsFalse(String.IsNullOrWhiteSpace(newListId));
List newlyAddedList = _config.Client.GetList(newListId).Result;
Assert.IsNotNull(newlyAddedList);
@ -97,7 +95,7 @@ namespace TMDbLibTests
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.IsFalse(String.IsNullOrWhiteSpace(newlyAddedList.CreatedBy));
Assert.IsTrue(_config.Client.ListDelete(newListId).Result);
}
@ -117,21 +115,21 @@ namespace TMDbLibTests
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
// Add a new movie to the list
Assert.IsTrue(_config.Client.ListAddMovie(TestListId, EvanAlmighty).Result);
Assert.IsTrue(_config.Client.ListAddMovie(TestListId, IdHelper.EvanAlmighty).Result);
// Try again, this time it should fail since the list already contains this movie
Assert.IsFalse(_config.Client.ListAddMovie(TestListId, EvanAlmighty).Result);
Assert.IsFalse(_config.Client.ListAddMovie(TestListId, IdHelper.EvanAlmighty).Result);
// Get list and check if the item was added
List listAfterAdd = _config.Client.GetList(TestListId).Result;
Assert.IsTrue(listAfterAdd.Items.Any(m => m.Id == EvanAlmighty));
Assert.IsTrue(listAfterAdd.Items.Any(m => m.Id == IdHelper.EvanAlmighty));
// Remove the previously added movie from the list
Assert.IsTrue(_config.Client.ListRemoveMovie(TestListId, EvanAlmighty).Result);
Assert.IsTrue(_config.Client.ListRemoveMovie(TestListId, IdHelper.EvanAlmighty).Result);
// Get list and check if the item was removed
List listAfterRemove = _config.Client.GetList(TestListId).Result;
Assert.IsFalse(listAfterRemove.Items.Any(m => m.Id == EvanAlmighty));
Assert.IsFalse(listAfterRemove.Items.Any(m => m.Id == IdHelper.EvanAlmighty));
}
[TestMethod]
@ -140,11 +138,11 @@ namespace TMDbLibTests
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
// Add a new movie to the list
Assert.IsTrue(_config.Client.ListAddMovie(TestListId, MadMaxFuryRoad).Result);
Assert.IsTrue(_config.Client.ListAddMovie(TestListId, IdHelper.MadMaxFuryRoad).Result);
// Get list and check if the item was added
List listAfterAdd = _config.Client.GetList(TestListId).Result;
Assert.IsTrue(listAfterAdd.Items.Any(m => m.Id == MadMaxFuryRoad));
Assert.IsTrue(listAfterAdd.Items.Any(m => m.Id == IdHelper.MadMaxFuryRoad));
// Clear the list
Assert.IsTrue(_config.Client.ListClear(TestListId).Result);

View File

@ -18,13 +18,6 @@ namespace TMDbLibTests
[TestClass]
public class ClientMovieTests
{
private const int Avatar = 19995;
private const int AGoodDayToDieHard = 47964;
private const int TheDarkKnightRises = 49026;
private const int MadMaxFuryRoad = 76341;
private const string AGoodDayToDieHardImdb = "tt1606378";
private const string TheDarkKnightRisesImdb = "tt1345836";
private static Dictionary<MovieMethods, Func<Movie, object>> _methods;
private TestConfig _config;
@ -61,7 +54,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestMoviesExtrasNone()
{
Movie movie = _config.Client.GetMovie(AGoodDayToDieHard).Result;
Movie movie = _config.Client.GetMovie(IdHelper.AGoodDayToDieHard).Result;
Assert.IsNotNull(movie);
@ -79,7 +72,7 @@ namespace TMDbLibTests
public void TestMoviesExtrasExclusive()
{
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetMovie(id, extras).Result, AGoodDayToDieHard);
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetMovie(id, extras).Result, IdHelper.AGoodDayToDieHard);
}
[TestMethod]
@ -91,10 +84,10 @@ namespace TMDbLibTests
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
// Account states will only show up if we've done something
_config.Client.MovieSetRating(TheDarkKnightRises, 5);
_config.Client.MovieSetRating(IdHelper.TheDarkKnightRises, 5);
MovieMethods combinedEnum = tmpMethods.Keys.Aggregate((methods, movieMethods) => methods | movieMethods);
Movie item = _config.Client.GetMovie(TheDarkKnightRises, combinedEnum).Result;
Movie item = _config.Client.GetMovie(IdHelper.TheDarkKnightRises, combinedEnum).Result;
TestMethodsHelper.TestAllNotNull(tmpMethods, item);
}
@ -104,7 +97,7 @@ namespace TMDbLibTests
{
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
MovieMethods combinedEnum = _methods.Keys.Aggregate((methods, movieMethods) => methods | movieMethods);
Movie item = _config.Client.GetMovie(AGoodDayToDieHard, combinedEnum).Result;
Movie item = _config.Client.GetMovie(IdHelper.AGoodDayToDieHard, combinedEnum).Result;
TestMethodsHelper.TestAllNotNull(_methods, item);
}
@ -112,8 +105,8 @@ namespace TMDbLibTests
[TestMethod]
public void TestMoviesLanguage()
{
Movie movie = _config.Client.GetMovie(AGoodDayToDieHard).Result;
Movie movieItalian = _config.Client.GetMovie(AGoodDayToDieHard, "it").Result;
Movie movie = _config.Client.GetMovie(IdHelper.AGoodDayToDieHard).Result;
Movie movieItalian = _config.Client.GetMovie(IdHelper.AGoodDayToDieHard, "it").Result;
Assert.IsNotNull(movie);
Assert.IsNotNull(movieItalian);
@ -133,10 +126,10 @@ namespace TMDbLibTests
public void TestMoviesGetMovieAlternativeTitles()
{
//GetMovieAlternativeTitles(int id, string country)
AlternativeTitles respUs = _config.Client.GetMovieAlternativeTitles(AGoodDayToDieHard, "US").Result;
AlternativeTitles respUs = _config.Client.GetMovieAlternativeTitles(IdHelper.AGoodDayToDieHard, "US").Result;
Assert.IsNotNull(respUs);
AlternativeTitles respFrench = _config.Client.GetMovieAlternativeTitles(AGoodDayToDieHard, "FR").Result;
AlternativeTitles respFrench = _config.Client.GetMovieAlternativeTitles(IdHelper.AGoodDayToDieHard, "FR").Result;
Assert.IsNotNull(respFrench);
Assert.IsFalse(respUs.Titles.Any(s => s.Title == "Duro de matar 5"));
@ -149,12 +142,12 @@ namespace TMDbLibTests
[TestMethod]
public void TestMoviesGetMovieAlternativeTitlesCountry()
{
AlternativeTitles respUs = _config.Client.GetMovieAlternativeTitles(AGoodDayToDieHard, "US").Result;
AlternativeTitles respUs = _config.Client.GetMovieAlternativeTitles(IdHelper.AGoodDayToDieHard, "US").Result;
Assert.IsNotNull(respUs);
_config.Client.DefaultCountry = "US";
AlternativeTitles respUs2 = _config.Client.GetMovieAlternativeTitles(AGoodDayToDieHard).Result;
AlternativeTitles respUs2 = _config.Client.GetMovieAlternativeTitles(IdHelper.AGoodDayToDieHard).Result;
Assert.IsNotNull(respUs2);
Assert.AreEqual(respUs.Titles.Count, respUs2.Titles.Count);
@ -163,7 +156,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestMoviesGetMovieCasts()
{
Credits resp = _config.Client.GetMovieCredits(AGoodDayToDieHard).Result;
Credits resp = _config.Client.GetMovieCredits(IdHelper.AGoodDayToDieHard).Result;
Assert.IsNotNull(resp);
Cast cast = resp.Cast.SingleOrDefault(s => s.Name == "Bruce Willis");
@ -192,7 +185,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestMoviesGetMovieImages()
{
ImagesWithId resp = _config.Client.GetMovieImages(AGoodDayToDieHard).Result;
ImagesWithId resp = _config.Client.GetMovieImages(IdHelper.AGoodDayToDieHard).Result;
Assert.IsNotNull(resp);
ImageData backdrop = resp.Backdrops.SingleOrDefault(s => s.FilePath == "/17zArExB7ztm6fjUXZwQWgGMC9f.jpg");
@ -221,7 +214,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestMoviesGetMovieKeywords()
{
KeywordsContainer resp = _config.Client.GetMovieKeywords(AGoodDayToDieHard).Result;
KeywordsContainer resp = _config.Client.GetMovieKeywords(IdHelper.AGoodDayToDieHard).Result;
Assert.IsNotNull(resp);
Keyword keyword = resp.Keywords.SingleOrDefault(s => s.Id == 186447);
@ -234,7 +227,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestMoviesGetMovieReleases()
{
Releases resp = _config.Client.GetMovieReleases(AGoodDayToDieHard).Result;
Releases resp = _config.Client.GetMovieReleases(IdHelper.AGoodDayToDieHard).Result;
Assert.IsNotNull(resp);
Country country = resp.Countries.SingleOrDefault(s => s.Iso_3166_1 == "US");
@ -249,7 +242,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestMoviesGetMovieVideos()
{
ResultContainer<Video> resp = _config.Client.GetMovieVideos(AGoodDayToDieHard).Result;
ResultContainer<Video> resp = _config.Client.GetMovieVideos(IdHelper.AGoodDayToDieHard).Result;
Assert.IsNotNull(resp);
Assert.IsNotNull(resp);
@ -270,7 +263,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestMoviesGetMovieTranslations()
{
TranslationsContainer resp = _config.Client.GetMovieTranslations(AGoodDayToDieHard).Result;
TranslationsContainer resp = _config.Client.GetMovieTranslations(IdHelper.AGoodDayToDieHard).Result;
Assert.IsNotNull(resp);
Translation translation = resp.Translations.SingleOrDefault(s => s.EnglishName == "German");
@ -284,10 +277,10 @@ namespace TMDbLibTests
[TestMethod]
public void TestMoviesGetMovieSimilarMovies()
{
SearchContainer<MovieResult> resp = _config.Client.GetMovieSimilar(AGoodDayToDieHard).Result;
SearchContainer<MovieResult> resp = _config.Client.GetMovieSimilar(IdHelper.AGoodDayToDieHard).Result;
Assert.IsNotNull(resp);
SearchContainer<MovieResult> respGerman = _config.Client.GetMovieSimilar(AGoodDayToDieHard, language: "de").Result;
SearchContainer<MovieResult> respGerman = _config.Client.GetMovieSimilar(IdHelper.AGoodDayToDieHard, language: "de").Result;
Assert.IsNotNull(respGerman);
Assert.AreEqual(resp.Results.Count, respGerman.Results.Count);
@ -307,7 +300,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestMoviesGetMovieReviews()
{
SearchContainer<Review> resp = _config.Client.GetMovieReviews(TheDarkKnightRises).Result;
SearchContainer<Review> resp = _config.Client.GetMovieReviews(IdHelper.TheDarkKnightRises).Result;
Assert.IsNotNull(resp);
Assert.AreNotEqual(0, resp.Results.Count);
@ -318,10 +311,10 @@ namespace TMDbLibTests
public void TestMoviesGetMovieLists()
{
//GetMovieLists(int id, string language, int page = -1)
SearchContainer<ListResult> resp = _config.Client.GetMovieLists(AGoodDayToDieHard).Result;
SearchContainer<ListResult> resp = _config.Client.GetMovieLists(IdHelper.AGoodDayToDieHard).Result;
Assert.IsNotNull(resp);
SearchContainer<ListResult> respPage2 = _config.Client.GetMovieLists(AGoodDayToDieHard, 2).Result;
SearchContainer<ListResult> respPage2 = _config.Client.GetMovieLists(IdHelper.AGoodDayToDieHard, 2).Result;
Assert.IsNotNull(respPage2);
Assert.AreEqual(1, resp.Page);
@ -364,9 +357,9 @@ namespace TMDbLibTests
_config.Client.GetConfig();
// Test image url generator
ImagesWithId images = _config.Client.GetMovieImages(AGoodDayToDieHard).Result;
ImagesWithId images = _config.Client.GetMovieImages(IdHelper.AGoodDayToDieHard).Result;
Assert.AreEqual(AGoodDayToDieHard, images.Id);
Assert.AreEqual(IdHelper.AGoodDayToDieHard, images.Id);
TestImagesHelpers.TestImages(_config, images);
}
@ -403,30 +396,30 @@ namespace TMDbLibTests
public void TestMoviesAccountStateFavoriteSet()
{
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
AccountState accountState = _config.Client.GetMovieAccountState(MadMaxFuryRoad).Result;
AccountState accountState = _config.Client.GetMovieAccountState(IdHelper.MadMaxFuryRoad).Result;
// Remove the favourite
if (accountState.Favorite)
_config.Client.AccountChangeFavoriteStatus(MediaType.Movie, MadMaxFuryRoad, false).Wait();
_config.Client.AccountChangeFavoriteStatus(MediaType.Movie, IdHelper.MadMaxFuryRoad, false).Wait();
// Allow TMDb to cache our changes
Thread.Sleep(2000);
// Test that the movie is NOT favourited
accountState = _config.Client.GetMovieAccountState(MadMaxFuryRoad).Result;
accountState = _config.Client.GetMovieAccountState(IdHelper.MadMaxFuryRoad).Result;
Assert.AreEqual(MadMaxFuryRoad, accountState.Id);
Assert.AreEqual(IdHelper.MadMaxFuryRoad, accountState.Id);
Assert.IsFalse(accountState.Favorite);
// Favourite the movie
_config.Client.AccountChangeFavoriteStatus(MediaType.Movie, MadMaxFuryRoad, true).Wait();
_config.Client.AccountChangeFavoriteStatus(MediaType.Movie, IdHelper.MadMaxFuryRoad, true).Wait();
// Allow TMDb to cache our changes
Thread.Sleep(2000);
// Test that the movie IS favourited
accountState = _config.Client.GetMovieAccountState(MadMaxFuryRoad).Result;
Assert.AreEqual(MadMaxFuryRoad, accountState.Id);
accountState = _config.Client.GetMovieAccountState(IdHelper.MadMaxFuryRoad).Result;
Assert.AreEqual(IdHelper.MadMaxFuryRoad, accountState.Id);
Assert.IsTrue(accountState.Favorite);
}
@ -434,30 +427,30 @@ namespace TMDbLibTests
public void TestMoviesAccountStateWatchlistSet()
{
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
AccountState accountState = _config.Client.GetMovieAccountState(MadMaxFuryRoad).Result;
AccountState accountState = _config.Client.GetMovieAccountState(IdHelper.MadMaxFuryRoad).Result;
// Remove the watchlist
if (accountState.Watchlist)
_config.Client.AccountChangeWatchlistStatus(MediaType.Movie, MadMaxFuryRoad, false).Wait();
_config.Client.AccountChangeWatchlistStatus(MediaType.Movie, IdHelper.MadMaxFuryRoad, false).Wait();
// Allow TMDb to cache our changes
Thread.Sleep(2000);
// Test that the movie is NOT watchlisted
accountState = _config.Client.GetMovieAccountState(MadMaxFuryRoad).Result;
accountState = _config.Client.GetMovieAccountState(IdHelper.MadMaxFuryRoad).Result;
Assert.AreEqual(MadMaxFuryRoad, accountState.Id);
Assert.AreEqual(IdHelper.MadMaxFuryRoad, accountState.Id);
Assert.IsFalse(accountState.Watchlist);
// Watchlist the movie
_config.Client.AccountChangeWatchlistStatus(MediaType.Movie, MadMaxFuryRoad, true).Wait();
_config.Client.AccountChangeWatchlistStatus(MediaType.Movie, IdHelper.MadMaxFuryRoad, true).Wait();
// Allow TMDb to cache our changes
Thread.Sleep(2000);
// Test that the movie IS watchlisted
accountState = _config.Client.GetMovieAccountState(MadMaxFuryRoad).Result;
Assert.AreEqual(MadMaxFuryRoad, accountState.Id);
accountState = _config.Client.GetMovieAccountState(IdHelper.MadMaxFuryRoad).Result;
Assert.AreEqual(IdHelper.MadMaxFuryRoad, accountState.Id);
Assert.IsTrue(accountState.Watchlist);
}
@ -465,57 +458,57 @@ namespace TMDbLibTests
public void TestMoviesAccountStateRatingSet()
{
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
AccountState accountState = _config.Client.GetMovieAccountState(MadMaxFuryRoad).Result;
AccountState accountState = _config.Client.GetMovieAccountState(IdHelper.MadMaxFuryRoad).Result;
// Remove the rating
if (accountState.Rating.HasValue)
{
Assert.IsTrue(_config.Client.MovieRemoveRating(MadMaxFuryRoad).Result);
Assert.IsTrue(_config.Client.MovieRemoveRating(IdHelper.MadMaxFuryRoad).Result);
// Allow TMDb to cache our changes
Thread.Sleep(2000);
}
// Test that the movie is NOT rated
accountState = _config.Client.GetMovieAccountState(MadMaxFuryRoad).Result;
accountState = _config.Client.GetMovieAccountState(IdHelper.MadMaxFuryRoad).Result;
Assert.AreEqual(MadMaxFuryRoad, accountState.Id);
Assert.AreEqual(IdHelper.MadMaxFuryRoad, accountState.Id);
Assert.IsFalse(accountState.Rating.HasValue);
// Rate the movie
_config.Client.MovieSetRating(MadMaxFuryRoad, 5).Wait();
_config.Client.MovieSetRating(IdHelper.MadMaxFuryRoad, 5).Wait();
// Allow TMDb to cache our changes
Thread.Sleep(2000);
// Test that the movie IS rated
accountState = _config.Client.GetMovieAccountState(MadMaxFuryRoad).Result;
Assert.AreEqual(MadMaxFuryRoad, accountState.Id);
accountState = _config.Client.GetMovieAccountState(IdHelper.MadMaxFuryRoad).Result;
Assert.AreEqual(IdHelper.MadMaxFuryRoad, accountState.Id);
Assert.IsTrue(accountState.Rating.HasValue);
// Remove the rating
Assert.IsTrue(_config.Client.MovieRemoveRating(MadMaxFuryRoad).Result);
Assert.IsTrue(_config.Client.MovieRemoveRating(IdHelper.MadMaxFuryRoad).Result);
}
[TestMethod]
public void TestMoviesSetRatingBadRating()
{
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
Assert.IsFalse(_config.Client.MovieSetRating(Avatar, 7.1).Result);
Assert.IsFalse(_config.Client.MovieSetRating(IdHelper.Avatar, 7.1).Result);
}
[TestMethod]
public void TestMoviesSetRatingRatingOutOfBounds()
{
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
Assert.IsFalse(_config.Client.MovieSetRating(Avatar, 10.5).Result);
Assert.IsFalse(_config.Client.MovieSetRating(IdHelper.Avatar, 10.5).Result);
}
[TestMethod]
public void TestMoviesSetRatingRatingLowerBoundsTest()
{
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
Assert.IsFalse(_config.Client.MovieSetRating(Avatar, 0).Result);
Assert.IsFalse(_config.Client.MovieSetRating(IdHelper.Avatar, 0).Result);
}
[TestMethod]
@ -524,39 +517,39 @@ namespace TMDbLibTests
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
// Ensure that the test movie has a different rating than our test rating
var rating = _config.Client.GetMovieAccountState(Avatar).Result.Rating;
var rating = _config.Client.GetMovieAccountState(IdHelper.Avatar).Result.Rating;
Assert.IsNotNull(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.MovieSetRating(Avatar, newRating).Result);
Assert.IsTrue(_config.Client.MovieSetRating(IdHelper.Avatar, newRating).Result);
// Allow TMDb to not cache our data
Thread.Sleep(2000);
// Check if it worked
Assert.AreEqual(newRating, _config.Client.GetMovieAccountState(Avatar).Result.Rating);
Assert.AreEqual(newRating, _config.Client.GetMovieAccountState(IdHelper.Avatar).Result.Rating);
// Try changing it back to the previous rating
Assert.IsTrue(_config.Client.MovieSetRating(Avatar, originalRating).Result);
Assert.IsTrue(_config.Client.MovieSetRating(IdHelper.Avatar, originalRating).Result);
// Allow TMDb to not cache our data
Thread.Sleep(2000);
// Check if it worked
Assert.AreEqual(originalRating, _config.Client.GetMovieAccountState(Avatar).Result.Rating);
Assert.AreEqual(originalRating, _config.Client.GetMovieAccountState(IdHelper.Avatar).Result.Rating);
}
[TestMethod]
public void TestMoviesGet()
{
Movie item = _config.Client.GetMovie(AGoodDayToDieHard).Result;
Movie item = _config.Client.GetMovie(IdHelper.AGoodDayToDieHard).Result;
Assert.IsNotNull(item);
Assert.AreEqual(AGoodDayToDieHard, item.Id);
Assert.AreEqual(AGoodDayToDieHardImdb, item.ImdbId);
Assert.AreEqual(IdHelper.AGoodDayToDieHard, item.Id);
Assert.AreEqual(IdHelper.AGoodDayToDieHardImdb, item.ImdbId);
// Check all properties
Assert.AreEqual("A Good Day to Die Hard", item.Title);
@ -598,15 +591,15 @@ namespace TMDbLibTests
// Test the custom parsing code for Account State rating
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
Movie movie = _config.Client.GetMovie(TheDarkKnightRises, MovieMethods.AccountStates).Result;
Movie movie = _config.Client.GetMovie(IdHelper.TheDarkKnightRises, MovieMethods.AccountStates).Result;
if (movie.AccountStates == null || !movie.AccountStates.Rating.HasValue)
{
_config.Client.MovieSetRating(TheDarkKnightRises, 5);
_config.Client.MovieSetRating(IdHelper.TheDarkKnightRises, 5);
// Allow TMDb to update cache
Thread.Sleep(2000);
movie = _config.Client.GetMovie(TheDarkKnightRises, MovieMethods.AccountStates).Result;
movie = _config.Client.GetMovie(IdHelper.TheDarkKnightRises, MovieMethods.AccountStates).Result;
}
Assert.IsNotNull(movie.AccountStates);

View File

@ -1,12 +1,12 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TMDbLib.Objects.TvShows;
using TMDbLibTests.Helpers;
namespace TMDbLibTests
{
[TestClass]
public class ClientNetworkTests
{
private const int Hbo = 49;
private TestConfig _config;
/// <summary>
@ -21,11 +21,11 @@ namespace TMDbLibTests
[TestMethod]
public void TestNetworkGetById()
{
Network network = _config.Client.GetNetwork(Hbo).Result;
Network network = _config.Client.GetNetwork(IdHelper.Hbo).Result;
Assert.IsNotNull(network);
Assert.AreEqual("HBO", network.Name);
Assert.AreEqual(Hbo, network.Id);
Assert.AreEqual(IdHelper.Hbo, network.Id);
}
}
}

View File

@ -13,8 +13,6 @@ namespace TMDbLibTests
[TestClass]
public class ClientPersonTests
{
private const int BruceWillis = 62;
private static Dictionary<PersonMethods, Func<Person, object>> _methods;
private TestConfig _config;
@ -45,7 +43,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestPersonsExtrasNone()
{
Person person = _config.Client.GetPerson(BruceWillis).Result;
Person person = _config.Client.GetPerson(IdHelper.BruceWillis).Result;
Assert.IsNotNull(person);
@ -61,14 +59,14 @@ namespace TMDbLibTests
[TestMethod]
public void TestPersonsExtrasExclusive()
{
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetPerson(id, extras).Result, BruceWillis);
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetPerson(id, extras).Result, IdHelper.BruceWillis);
}
[TestMethod]
public void TestPersonsExtrasAll()
{
PersonMethods combinedEnum = _methods.Keys.Aggregate((methods, movieMethods) => methods | movieMethods);
Person item = _config.Client.GetPerson(BruceWillis, combinedEnum).Result;
Person item = _config.Client.GetPerson(IdHelper.BruceWillis, combinedEnum).Result;
TestMethodsHelper.TestAllNotNull(_methods, item);
}
@ -76,7 +74,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestPersonsGet()
{
Person item = _config.Client.GetPerson(BruceWillis).Result;
Person item = _config.Client.GetPerson(IdHelper.BruceWillis).Result;
Assert.IsNotNull(item);
Assert.AreEqual(false, item.Adult);
@ -101,13 +99,13 @@ namespace TMDbLibTests
[TestMethod]
public void TestPersonsGetPersonTvCredits()
{
TvCredits item = _config.Client.GetPersonTvCredits(BruceWillis).Result;
TvCredits item = _config.Client.GetPersonTvCredits(IdHelper.BruceWillis).Result;
Assert.IsNotNull(item);
Assert.IsNotNull(item.Cast);
Assert.IsNotNull(item.Crew);
Assert.AreEqual(BruceWillis, item.Id);
Assert.AreEqual(IdHelper.BruceWillis, item.Id);
TvRole cast = item.Cast.SingleOrDefault(s => s.Character == "David Addison Jr.");
Assert.IsNotNull(cast);
@ -136,13 +134,13 @@ namespace TMDbLibTests
[TestMethod]
public void TestPersonsGetPersonMovieCredits()
{
MovieCredits item = _config.Client.GetPersonMovieCredits(BruceWillis).Result;
MovieCredits item = _config.Client.GetPersonMovieCredits(IdHelper.BruceWillis).Result;
Assert.IsNotNull(item);
Assert.IsNotNull(item.Cast);
Assert.IsNotNull(item.Crew);
Assert.AreEqual(BruceWillis, item.Id);
Assert.AreEqual(IdHelper.BruceWillis, item.Id);
MovieRole cast = item.Cast.SingleOrDefault(s => s.CreditId == "52fe4329c3a36847f803f193");
Assert.IsNotNull(cast);
@ -171,11 +169,11 @@ namespace TMDbLibTests
[TestMethod]
public void TestPersonsGetPersonExternalIds()
{
ExternalIds item = _config.Client.GetPersonExternalIds(BruceWillis).Result;
ExternalIds item = _config.Client.GetPersonExternalIds(IdHelper.BruceWillis).Result;
Assert.IsNotNull(item);
Assert.AreEqual(BruceWillis, item.Id);
Assert.AreEqual(IdHelper.BruceWillis, item.Id);
Assert.AreEqual("nm0000246", item.ImdbId);
Assert.AreEqual("/m/0h7pj", item.FreebaseMid);
Assert.AreEqual("/en/bruce_willis", item.FreebaseId);
@ -187,10 +185,10 @@ namespace TMDbLibTests
public void TestPersonsGetPersonCredits()
{
//GetPersonCredits(int id, string language)
MovieCredits resp = _config.Client.GetPersonMovieCredits(BruceWillis).Result;
MovieCredits resp = _config.Client.GetPersonMovieCredits(IdHelper.BruceWillis).Result;
Assert.IsNotNull(resp);
MovieCredits respItalian = _config.Client.GetPersonMovieCredits(BruceWillis, "it").Result;
MovieCredits respItalian = _config.Client.GetPersonMovieCredits(IdHelper.BruceWillis, "it").Result;
Assert.IsNotNull(respItalian);
Assert.AreEqual(resp.Cast.Count, respItalian.Cast.Count);
@ -255,11 +253,11 @@ namespace TMDbLibTests
_config.Client.GetConfig();
// Get images
ProfileImages images = _config.Client.GetPersonImages(BruceWillis).Result;
ProfileImages images = _config.Client.GetPersonImages(IdHelper.BruceWillis).Result;
Assert.IsNotNull(images);
Assert.IsNotNull(images.Profiles);
Assert.AreEqual(BruceWillis, images.Id);
Assert.AreEqual(IdHelper.BruceWillis, images.Id);
// Test image url generator
TestImagesHelpers.TestImages(_config, images);
@ -283,9 +281,9 @@ namespace TMDbLibTests
_config.Client.GetConfig();
// Get images
TestHelpers.SearchPages(i => _config.Client.GetPersonTaggedImages(BruceWillis, i).Result);
TestHelpers.SearchPages(i => _config.Client.GetPersonTaggedImages(IdHelper.BruceWillis, i).Result);
SearchContainer<TaggedImage> images = _config.Client.GetPersonTaggedImages(BruceWillis, 1).Result;
SearchContainer<TaggedImage> images = _config.Client.GetPersonTaggedImages(IdHelper.BruceWillis, 1).Result;
Assert.IsNotNull(images);
Assert.IsNotNull(images.Results);

View File

@ -1,6 +1,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TMDbLib.Objects.Reviews;
using TMDbLib.Objects.General;
using TMDbLibTests.Helpers;
namespace TMDbLibTests
{
@ -8,7 +9,6 @@ namespace TMDbLibTests
public class ClientReviewTests
{
private TestConfig _config;
private const string TheDarkKnightRisesReviewId = "5010553819c2952d1b000451";
/// <summary>
/// Run once, on every test
@ -22,11 +22,11 @@ namespace TMDbLibTests
[TestMethod]
public void TestReviewFullDetails()
{
Review review = _config.Client.GetReview(TheDarkKnightRisesReviewId).Result;
Review review = _config.Client.GetReview(IdHelper.TheDarkKnightRisesReviewId).Result;
Assert.IsNotNull(review);
Assert.AreEqual(TheDarkKnightRisesReviewId, review.Id);
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);

View File

@ -17,10 +17,6 @@ namespace TMDbLibTests
[TestClass]
public class ClientTvEpisodeTests
{
private const int BreakingBad = 1396;
private const int BreakingBadSeason1Episode1Id = 62085;
private const int BigBangTheory = 1418;
private static Dictionary<TvEpisodeMethods, Func<TvEpisode, object>> _methods;
private TestConfig _config;
@ -50,7 +46,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestTvEpisodeExtrasNone()
{
TvEpisode tvEpisode = _config.Client.GetTvEpisode(BreakingBad, 1, 1).Result;
TvEpisode tvEpisode = _config.Client.GetTvEpisode(IdHelper.BreakingBad, 1, 1).Result;
TestBreakingBadSeasonOneEpisodeOneBaseProperties(tvEpisode);
@ -67,15 +63,15 @@ namespace TMDbLibTests
// Test the custom parsing code for Account State rating
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
TvEpisode episode = _config.Client.GetTvEpisode(BigBangTheory, 1, 1, TvEpisodeMethods.AccountStates).Result;
TvEpisode episode = _config.Client.GetTvEpisode(IdHelper.BigBangTheory, 1, 1, TvEpisodeMethods.AccountStates).Result;
if (episode.AccountStates == null || !episode.AccountStates.Rating.HasValue)
{
_config.Client.TvEpisodeSetRating(BigBangTheory, 1, 1, 5);
_config.Client.TvEpisodeSetRating(IdHelper.BigBangTheory, 1, 1, 5);
// Allow TMDb to update cache
Thread.Sleep(2000);
episode = _config.Client.GetTvEpisode(BigBangTheory, 1, 1, TvEpisodeMethods.AccountStates).Result;
episode = _config.Client.GetTvEpisode(IdHelper.BigBangTheory, 1, 1, TvEpisodeMethods.AccountStates).Result;
}
Assert.IsNotNull(episode.AccountStates);
@ -89,10 +85,10 @@ namespace TMDbLibTests
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
// Account states will only show up if we've done something
_config.Client.TvEpisodeSetRating(BreakingBad, 1, 1, 5);
_config.Client.TvEpisodeSetRating(IdHelper.BreakingBad, 1, 1, 5);
TvEpisodeMethods combinedEnum = _methods.Keys.Aggregate((methods, tvEpisodeMethods) => methods | tvEpisodeMethods);
TvEpisode tvEpisode = _config.Client.GetTvEpisode(BreakingBad, 1, 1, combinedEnum).Result;
TvEpisode tvEpisode = _config.Client.GetTvEpisode(IdHelper.BreakingBad, 1, 1, combinedEnum).Result;
TestBreakingBadSeasonOneEpisodeOneBaseProperties(tvEpisode);
@ -107,13 +103,13 @@ namespace TMDbLibTests
public void TestTvEpisodeExtrasExclusive()
{
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetTvEpisode(id, 1, 1, extras).Result, BreakingBad);
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetTvEpisode(id, 1, 1, extras).Result, IdHelper.BreakingBad);
}
[TestMethod]
public void TestTvEpisodeSeparateExtrasCredits()
{
Credits credits = _config.Client.GetTvEpisodeCredits(BreakingBad, 1, 1).Result;
Credits credits = _config.Client.GetTvEpisodeCredits(IdHelper.BreakingBad, 1, 1).Result;
Assert.IsNotNull(credits);
Assert.IsNotNull(credits.Cast);
Assert.AreEqual("Walter White", credits.Cast[0].Character);
@ -136,7 +132,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestTvEpisodeSeparateExtrasExternalIds()
{
ExternalIds externalIds = _config.Client.GetTvEpisodeExternalIds(BreakingBad, 1, 1).Result;
ExternalIds externalIds = _config.Client.GetTvEpisodeExternalIds(IdHelper.BreakingBad, 1, 1).Result;
Assert.IsNotNull(externalIds);
Assert.IsTrue(string.IsNullOrEmpty(externalIds.FreebaseId));
Assert.AreEqual(62085, externalIds.Id);
@ -149,7 +145,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestTvEpisodeSeparateExtrasImages()
{
StillImages images = _config.Client.GetTvEpisodeImages(BreakingBad, 1, 1).Result;
StillImages images = _config.Client.GetTvEpisodeImages(IdHelper.BreakingBad, 1, 1).Result;
Assert.IsNotNull(images);
Assert.IsNotNull(images.Stills);
}
@ -157,7 +153,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestTvEpisodeSeparateExtrasVideos()
{
ResultContainer<Video> images = _config.Client.GetTvEpisodeVideos(BreakingBad, 1, 1).Result;
ResultContainer<Video> images = _config.Client.GetTvEpisodeVideos(IdHelper.BreakingBad, 1, 1).Result;
Assert.IsNotNull(images);
Assert.IsNotNull(images.Results);
}
@ -166,36 +162,36 @@ namespace TMDbLibTests
public void TestTvEpisodeAccountStateRatingSet()
{
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
TvEpisodeAccountState accountState = _config.Client.GetTvEpisodeAccountState(BreakingBad, 1, 1).Result;
TvEpisodeAccountState accountState = _config.Client.GetTvEpisodeAccountState(IdHelper.BreakingBad, 1, 1).Result;
// Remove the rating
if (accountState.Rating.HasValue)
{
Assert.IsTrue(_config.Client.TvEpisodeRemoveRating(BreakingBad, 1, 1).Result);
Assert.IsTrue(_config.Client.TvEpisodeRemoveRating(IdHelper.BreakingBad, 1, 1).Result);
// Allow TMDb to cache our changes
Thread.Sleep(2000);
}
// Test that the episode is NOT rated
accountState = _config.Client.GetTvEpisodeAccountState(BreakingBad, 1, 1).Result;
accountState = _config.Client.GetTvEpisodeAccountState(IdHelper.BreakingBad, 1, 1).Result;
Assert.AreEqual(BreakingBadSeason1Episode1Id, accountState.Id);
Assert.AreEqual(IdHelper.BreakingBadSeason1Episode1Id, accountState.Id);
Assert.IsFalse(accountState.Rating.HasValue);
// Rate the episode
Assert.IsTrue(_config.Client.TvEpisodeSetRating(BreakingBad, 1, 1, 5).Result);
Assert.IsTrue(_config.Client.TvEpisodeSetRating(IdHelper.BreakingBad, 1, 1, 5).Result);
// Allow TMDb to cache our changes
Thread.Sleep(2000);
// Test that the episode IS rated
accountState = _config.Client.GetTvEpisodeAccountState(BreakingBad, 1, 1).Result;
Assert.AreEqual(BreakingBadSeason1Episode1Id, accountState.Id);
accountState = _config.Client.GetTvEpisodeAccountState(IdHelper.BreakingBad, 1, 1).Result;
Assert.AreEqual(IdHelper.BreakingBadSeason1Episode1Id, accountState.Id);
Assert.IsTrue(accountState.Rating.HasValue);
// Remove the rating
Assert.IsTrue(_config.Client.TvEpisodeRemoveRating(BreakingBad, 1, 1).Result);
Assert.IsTrue(_config.Client.TvEpisodeRemoveRating(IdHelper.BreakingBad, 1, 1).Result);
}
[TestMethod]
@ -203,15 +199,15 @@ namespace TMDbLibTests
{
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
Assert.IsFalse(_config.Client.TvEpisodeSetRating(BreakingBad, 1, 1, -1).Result);
Assert.IsFalse(_config.Client.TvEpisodeSetRating(BreakingBad, 1, 1, 0).Result);
Assert.IsFalse(_config.Client.TvEpisodeSetRating(BreakingBad, 1, 1, 10.5).Result);
Assert.IsFalse(_config.Client.TvEpisodeSetRating(IdHelper.BreakingBad, 1, 1, -1).Result);
Assert.IsFalse(_config.Client.TvEpisodeSetRating(IdHelper.BreakingBad, 1, 1, 0).Result);
Assert.IsFalse(_config.Client.TvEpisodeSetRating(IdHelper.BreakingBad, 1, 1, 10.5).Result);
}
[TestMethod]
public void TestTvEpisodeGetChanges()
{
ChangesContainer changes = _config.Client.GetTvEpisodeChanges(BreakingBadSeason1Episode1Id).Result;
ChangesContainer changes = _config.Client.GetTvEpisodeChanges(IdHelper.BreakingBadSeason1Episode1Id).Result;
Assert.IsNotNull(changes);
Assert.IsNotNull(changes.Changes);

View File

@ -17,10 +17,6 @@ namespace TMDbLibTests
[TestClass]
public class ClientTvSeasonTests
{
private const int BreakingBad = 1396;
private const int BreakingBadSeason1Id = 3572;
private const int BigBangTheory = 1418;
private static Dictionary<TvSeasonMethods, Func<TvSeason, object>> _methods;
private TestConfig _config;
@ -51,7 +47,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestTvSeasonExtrasNone()
{
TvSeason tvSeason = _config.Client.GetTvSeason(BreakingBad, 1).Result;
TvSeason tvSeason = _config.Client.GetTvSeason(IdHelper.BreakingBad, 1).Result;
TestBreakingBadBaseProperties(tvSeason);
@ -68,15 +64,15 @@ namespace TMDbLibTests
// Test the custom parsing code for Account State rating
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
TvSeason season = _config.Client.GetTvSeason(BigBangTheory, 1, TvSeasonMethods.AccountStates).Result;
TvSeason season = _config.Client.GetTvSeason(IdHelper.BigBangTheory, 1, TvSeasonMethods.AccountStates).Result;
if (season.AccountStates == null || season.AccountStates.Results.All(s => s.EpisodeNumber != 1))
{
_config.Client.TvEpisodeSetRating(BigBangTheory, 1, 1, 5);
_config.Client.TvEpisodeSetRating(IdHelper.BigBangTheory, 1, 1, 5);
// Allow TMDb to update cache
Thread.Sleep(2000);
season = _config.Client.GetTvSeason(BigBangTheory, 1, TvSeasonMethods.AccountStates).Result;
season = _config.Client.GetTvSeason(IdHelper.BigBangTheory, 1, TvSeasonMethods.AccountStates).Result;
}
Assert.IsNotNull(season.AccountStates);
@ -90,10 +86,10 @@ namespace TMDbLibTests
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
// Account states will only show up if we've done something
_config.Client.TvEpisodeSetRating(BreakingBad, 1, 1, 5);
_config.Client.TvEpisodeSetRating(IdHelper.BreakingBad, 1, 1, 5);
TvSeasonMethods combinedEnum = _methods.Keys.Aggregate((methods, tvSeasonMethods) => methods | tvSeasonMethods);
TvSeason tvSeason = _config.Client.GetTvSeason(BreakingBad, 1, combinedEnum).Result;
TvSeason tvSeason = _config.Client.GetTvSeason(IdHelper.BreakingBad, 1, combinedEnum).Result;
TestBreakingBadBaseProperties(tvSeason);
@ -104,13 +100,13 @@ namespace TMDbLibTests
public void TestTvSeasonExtrasExclusive()
{
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetTvSeason(id, 1, extras).Result, BreakingBad);
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetTvSeason(id, 1, extras).Result, IdHelper.BreakingBad);
}
[TestMethod]
public void TestTvSeasonSeparateExtrasCredits()
{
Credits credits = _config.Client.GetTvSeasonCredits(BreakingBad, 1).Result;
Credits credits = _config.Client.GetTvSeasonCredits(IdHelper.BreakingBad, 1).Result;
Assert.IsNotNull(credits);
Assert.IsNotNull(credits.Cast);
Assert.AreEqual("Walter White", credits.Cast[0].Character);
@ -133,7 +129,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestTvSeasonSeparateExtrasExternalIds()
{
ExternalIds externalIds = _config.Client.GetTvSeasonExternalIds(BreakingBad, 1).Result;
ExternalIds externalIds = _config.Client.GetTvSeasonExternalIds(IdHelper.BreakingBad, 1).Result;
Assert.IsNotNull(externalIds);
Assert.AreEqual(3572, externalIds.Id);
Assert.AreEqual("/en/breaking_bad_season_1", externalIds.FreebaseId);
@ -146,7 +142,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestTvSeasonSeparateExtrasImages()
{
PosterImages images = _config.Client.GetTvSeasonImages(BreakingBad, 1).Result;
PosterImages images = _config.Client.GetTvSeasonImages(IdHelper.BreakingBad, 1).Result;
Assert.IsNotNull(images);
Assert.IsNotNull(images.Posters);
}
@ -154,7 +150,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestTvSeasonSeparateExtrasVideos()
{
ResultContainer<Video> videos = _config.Client.GetTvSeasonVideos(BreakingBad, 1).Result;
ResultContainer<Video> videos = _config.Client.GetTvSeasonVideos(IdHelper.BreakingBad, 1).Result;
Assert.IsNotNull(videos);
Assert.IsNotNull(videos.Results);
}
@ -162,7 +158,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestTvSeasonEpisodeCount()
{
TvSeason season = _config.Client.GetTvSeason(BreakingBad, 1).Result;
TvSeason season = _config.Client.GetTvSeason(IdHelper.BreakingBad, 1).Result;
Assert.IsNotNull(season);
Assert.IsNotNull(season.Episodes);
@ -175,15 +171,15 @@ namespace TMDbLibTests
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
// Rate episode 1, 2 and 3 of BreakingBad
Assert.IsTrue(_config.Client.TvEpisodeSetRating(BreakingBad, 1, 1, 5).Result);
Assert.IsTrue(_config.Client.TvEpisodeSetRating(BreakingBad, 1, 2, 7).Result);
Assert.IsTrue(_config.Client.TvEpisodeSetRating(BreakingBad, 1, 3, 3).Result);
Assert.IsTrue(_config.Client.TvEpisodeSetRating(IdHelper.BreakingBad, 1, 1, 5).Result);
Assert.IsTrue(_config.Client.TvEpisodeSetRating(IdHelper.BreakingBad, 1, 2, 7).Result);
Assert.IsTrue(_config.Client.TvEpisodeSetRating(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.GetTvSeasonAccountState(BreakingBad, 1).Result;
ResultContainer<TvEpisodeAccountState> state = _config.Client.GetTvSeasonAccountState(IdHelper.BreakingBad, 1).Result;
Assert.IsNotNull(state);
Assert.IsTrue(Math.Abs(5 - (state.Results.Single(s => s.EpisodeNumber == 1).Rating ?? 0)) < double.Epsilon);
@ -191,14 +187,14 @@ namespace TMDbLibTests
Assert.IsTrue(Math.Abs(3 - (state.Results.Single(s => s.EpisodeNumber == 3).Rating ?? 0)) < double.Epsilon);
// Test deleting Ratings
Assert.IsTrue(_config.Client.TvEpisodeRemoveRating(BreakingBad, 1, 1).Result);
Assert.IsTrue(_config.Client.TvEpisodeRemoveRating(BreakingBad, 1, 2).Result);
Assert.IsTrue(_config.Client.TvEpisodeRemoveRating(BreakingBad, 1, 3).Result);
Assert.IsTrue(_config.Client.TvEpisodeRemoveRating(IdHelper.BreakingBad, 1, 1).Result);
Assert.IsTrue(_config.Client.TvEpisodeRemoveRating(IdHelper.BreakingBad, 1, 2).Result);
Assert.IsTrue(_config.Client.TvEpisodeRemoveRating(IdHelper.BreakingBad, 1, 3).Result);
// Wait for TMDb to un-cache our value
Thread.Sleep(2000);
state = _config.Client.GetTvSeasonAccountState(BreakingBad, 1).Result;
state = _config.Client.GetTvSeasonAccountState(IdHelper.BreakingBad, 1).Result;
Assert.IsNotNull(state);
Assert.IsNull(state.Results.Single(s => s.EpisodeNumber == 1).Rating);
@ -209,7 +205,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestTvSeasonGetChanges()
{
ChangesContainer changes = _config.Client.GetTvSeasonChanges(BreakingBadSeason1Id).Result;
ChangesContainer changes = _config.Client.GetTvSeasonChanges(IdHelper.BreakingBadSeason1Id).Result;
Assert.IsNotNull(changes);
Assert.IsNotNull(changes.Changes);
}

View File

@ -17,10 +17,6 @@ namespace TMDbLibTests
[TestClass]
public class ClientTvShowTests
{
private const int BreakingBad = 1396;
private const int BigBangTheory = 1418;
private const int House = 1408;
private static Dictionary<TvShowMethods, Func<TvShow, object>> _methods;
private TestConfig _config;
@ -53,7 +49,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestTvShowExtrasNone()
{
TvShow tvShow = _config.Client.GetTvShow(BreakingBad).Result;
TvShow tvShow = _config.Client.GetTvShow(IdHelper.BreakingBad).Result;
TestBreakingBadBaseProperties(tvShow);
@ -68,10 +64,10 @@ namespace TMDbLibTests
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
// Account states will only show up if we've done something
_config.Client.TvShowSetRating(BreakingBad, 5);
_config.Client.TvShowSetRating(IdHelper.BreakingBad, 5);
TvShowMethods combinedEnum = _methods.Keys.Aggregate((methods, tvShowMethods) => methods | tvShowMethods);
TvShow tvShow = _config.Client.GetTvShow(BreakingBad, combinedEnum).Result;
TvShow tvShow = _config.Client.GetTvShow(IdHelper.BreakingBad, combinedEnum).Result;
TestBreakingBadBaseProperties(tvShow);
@ -81,11 +77,11 @@ namespace TMDbLibTests
[TestMethod]
public void TestTvShowSeparateExtrasCredits()
{
Credits credits = _config.Client.GetTvShowCredits(BreakingBad).Result;
Credits credits = _config.Client.GetTvShowCredits(IdHelper.BreakingBad).Result;
Assert.IsNotNull(credits);
Assert.IsNotNull(credits.Cast);
Assert.AreEqual(BreakingBad, credits.Id);
Assert.AreEqual(IdHelper.BreakingBad, credits.Id);
Cast castPerson = credits.Cast[0];
Assert.AreEqual("Walter White", castPerson.Character);
@ -111,7 +107,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestTvShowSeparateExtrasExternalIds()
{
ExternalIds externalIds = _config.Client.GetTvShowExternalIds(BreakingBad).Result;
ExternalIds externalIds = _config.Client.GetTvShowExternalIds(IdHelper.BreakingBad).Result;
Assert.IsNotNull(externalIds);
Assert.AreEqual(1396, externalIds.Id);
Assert.AreEqual("/en/breaking_bad", externalIds.FreebaseId);
@ -125,9 +121,9 @@ namespace TMDbLibTests
[TestMethod]
public void TestTvShowSeparateExtrasContentRatings()
{
ResultContainer<ContentRating> contentRatings = _config.Client.GetTvShowContentRatings(BreakingBad).Result;
ResultContainer<ContentRating> contentRatings = _config.Client.GetTvShowContentRatings(IdHelper.BreakingBad).Result;
Assert.IsNotNull(contentRatings);
Assert.AreEqual(BreakingBad, contentRatings.Id);
Assert.AreEqual(IdHelper.BreakingBad, contentRatings.Id);
ContentRating contentRating = contentRatings.Results.FirstOrDefault(r => r.Iso_3166_1.Equals("US"));
Assert.IsNotNull(contentRating);
@ -137,9 +133,9 @@ namespace TMDbLibTests
[TestMethod]
public void TestTvShowSeparateExtrasAlternativeTitles()
{
ResultContainer<AlternativeTitle> alternativeTitles = _config.Client.GetTvShowAlternativeTitles(BreakingBad).Result;
ResultContainer<AlternativeTitle> alternativeTitles = _config.Client.GetTvShowAlternativeTitles(IdHelper.BreakingBad).Result;
Assert.IsNotNull(alternativeTitles);
Assert.AreEqual(BreakingBad, alternativeTitles.Id);
Assert.AreEqual(IdHelper.BreakingBad, alternativeTitles.Id);
AlternativeTitle alternativeTitle = alternativeTitles.Results.FirstOrDefault(r => r.Iso_3166_1.Equals("HU"));
Assert.IsNotNull(alternativeTitle);
@ -149,9 +145,9 @@ namespace TMDbLibTests
[TestMethod]
public void TestTvShowSeparateExtrasKeywords()
{
ResultContainer<Keyword> keywords = _config.Client.GetTvShowKeywords(BreakingBad).Result;
ResultContainer<Keyword> keywords = _config.Client.GetTvShowKeywords(IdHelper.BreakingBad).Result;
Assert.IsNotNull(keywords);
Assert.AreEqual(BreakingBad, keywords.Id);
Assert.AreEqual(IdHelper.BreakingBad, keywords.Id);
Keyword keyword = keywords.Results.FirstOrDefault(r => r.Id == 41525);
Assert.IsNotNull(keyword);
@ -161,9 +157,9 @@ namespace TMDbLibTests
[TestMethod]
public void TestTvShowSeparateExtrasTranslations()
{
TranslationsContainer translations = _config.Client.GetTvShowTranslations(BreakingBad).Result;
TranslationsContainer translations = _config.Client.GetTvShowTranslations(IdHelper.BreakingBad).Result;
Assert.IsNotNull(translations);
Assert.AreEqual(BreakingBad, translations.Id);
Assert.AreEqual(IdHelper.BreakingBad, translations.Id);
Translation translation = translations.Translations.FirstOrDefault(r => r.Iso_639_1 == "hr");
Assert.IsNotNull(translation);
@ -175,9 +171,9 @@ namespace TMDbLibTests
[TestMethod]
public void TestTvShowSeparateExtrasVideos()
{
ResultContainer<Video> videos = _config.Client.GetTvShowVideos(BreakingBad).Result;
ResultContainer<Video> videos = _config.Client.GetTvShowVideos(IdHelper.BreakingBad).Result;
Assert.IsNotNull(videos);
Assert.AreEqual(BreakingBad, videos.Id);
Assert.AreEqual(IdHelper.BreakingBad, videos.Id);
Video video = videos.Results.FirstOrDefault(r => r.Id == "5335e299c3a368265000001d");
Assert.IsNotNull(video);
@ -197,15 +193,15 @@ namespace TMDbLibTests
// Test the custom parsing code for Account State rating
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
TvShow show = _config.Client.GetTvShow(BigBangTheory, TvShowMethods.AccountStates).Result;
TvShow show = _config.Client.GetTvShow(IdHelper.BigBangTheory, TvShowMethods.AccountStates).Result;
if (show.AccountStates == null || !show.AccountStates.Rating.HasValue)
{
_config.Client.TvShowSetRating(BigBangTheory, 5);
_config.Client.TvShowSetRating(IdHelper.BigBangTheory, 5);
// Allow TMDb to update cache
Thread.Sleep(2000);
show = _config.Client.GetTvShow(BigBangTheory, TvShowMethods.AccountStates).Result;
show = _config.Client.GetTvShow(IdHelper.BigBangTheory, TvShowMethods.AccountStates).Result;
}
Assert.IsNotNull(show.AccountStates);
@ -216,7 +212,7 @@ namespace TMDbLibTests
[TestMethod]
public void TestTvShowSeparateExtrasImages()
{
ImagesWithId images = _config.Client.GetTvShowImages(BreakingBad).Result;
ImagesWithId images = _config.Client.GetTvShowImages(IdHelper.BreakingBad).Result;
Assert.IsNotNull(images);
Assert.IsNotNull(images.Backdrops);
Assert.IsNotNull(images.Posters);
@ -402,30 +398,30 @@ namespace TMDbLibTests
public void TestTvShowAccountStateFavoriteSet()
{
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
AccountState accountState = _config.Client.GetTvShowAccountState(BreakingBad).Result;
AccountState accountState = _config.Client.GetTvShowAccountState(IdHelper.BreakingBad).Result;
// Remove the favourite
if (accountState.Favorite)
_config.Client.AccountChangeFavoriteStatus(MediaType.TVShow, BreakingBad, false).Wait();
_config.Client.AccountChangeFavoriteStatus(MediaType.TVShow, IdHelper.BreakingBad, false).Wait();
// Allow TMDb to cache our changes
Thread.Sleep(2000);
// Test that the movie is NOT favourited
accountState = _config.Client.GetTvShowAccountState(BreakingBad).Result;
accountState = _config.Client.GetTvShowAccountState(IdHelper.BreakingBad).Result;
Assert.AreEqual(BreakingBad, accountState.Id);
Assert.AreEqual(IdHelper.BreakingBad, accountState.Id);
Assert.IsFalse(accountState.Favorite);
// Favourite the movie
_config.Client.AccountChangeFavoriteStatus(MediaType.TVShow, BreakingBad, true).Wait();
_config.Client.AccountChangeFavoriteStatus(MediaType.TVShow, IdHelper.BreakingBad, true).Wait();
// Allow TMDb to cache our changes
Thread.Sleep(2000);
// Test that the movie IS favourited
accountState = _config.Client.GetTvShowAccountState(BreakingBad).Result;
Assert.AreEqual(BreakingBad, accountState.Id);
accountState = _config.Client.GetTvShowAccountState(IdHelper.BreakingBad).Result;
Assert.AreEqual(IdHelper.BreakingBad, accountState.Id);
Assert.IsTrue(accountState.Favorite);
}
@ -433,30 +429,30 @@ namespace TMDbLibTests
public void TestTvShowAccountStateWatchlistSet()
{
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
AccountState accountState = _config.Client.GetTvShowAccountState(BreakingBad).Result;
AccountState accountState = _config.Client.GetTvShowAccountState(IdHelper.BreakingBad).Result;
// Remove the watchlist
if (accountState.Watchlist)
_config.Client.AccountChangeWatchlistStatus(MediaType.TVShow, BreakingBad, false).Wait();
_config.Client.AccountChangeWatchlistStatus(MediaType.TVShow, IdHelper.BreakingBad, false).Wait();
// Allow TMDb to cache our changes
Thread.Sleep(2000);
// Test that the movie is NOT watchlisted
accountState = _config.Client.GetTvShowAccountState(BreakingBad).Result;
accountState = _config.Client.GetTvShowAccountState(IdHelper.BreakingBad).Result;
Assert.AreEqual(BreakingBad, accountState.Id);
Assert.AreEqual(IdHelper.BreakingBad, accountState.Id);
Assert.IsFalse(accountState.Watchlist);
// Watchlist the movie
_config.Client.AccountChangeWatchlistStatus(MediaType.TVShow, BreakingBad, true).Wait();
_config.Client.AccountChangeWatchlistStatus(MediaType.TVShow, IdHelper.BreakingBad, true).Wait();
// Allow TMDb to cache our changes
Thread.Sleep(2000);
// Test that the movie IS watchlisted
accountState = _config.Client.GetTvShowAccountState(BreakingBad).Result;
Assert.AreEqual(BreakingBad, accountState.Id);
accountState = _config.Client.GetTvShowAccountState(IdHelper.BreakingBad).Result;
Assert.AreEqual(IdHelper.BreakingBad, accountState.Id);
Assert.IsTrue(accountState.Watchlist);
}
@ -464,12 +460,12 @@ namespace TMDbLibTests
public void TestTvShowAccountStateRatingSet()
{
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
AccountState accountState = _config.Client.GetTvShowAccountState(BreakingBad).Result;
AccountState accountState = _config.Client.GetTvShowAccountState(IdHelper.BreakingBad).Result;
// Remove the rating
if (accountState.Rating.HasValue)
{
Assert.IsTrue(_config.Client.TvShowRemoveRating(BreakingBad).Result);
Assert.IsTrue(_config.Client.TvShowRemoveRating(IdHelper.BreakingBad).Result);
// Allow TMDb to cache our changes
Thread.Sleep(2000);
@ -479,81 +475,81 @@ namespace TMDbLibTests
Thread.Sleep(2000);
// Test that the movie is NOT rated
accountState = _config.Client.GetTvShowAccountState(BreakingBad).Result;
accountState = _config.Client.GetTvShowAccountState(IdHelper.BreakingBad).Result;
Assert.AreEqual(BreakingBad, accountState.Id);
Assert.AreEqual(IdHelper.BreakingBad, accountState.Id);
Assert.IsFalse(accountState.Rating.HasValue);
// Rate the movie
_config.Client.TvShowSetRating(BreakingBad, 5).Wait();
_config.Client.TvShowSetRating(IdHelper.BreakingBad, 5).Wait();
// Allow TMDb to cache our changes
Thread.Sleep(2000);
// Test that the movie IS rated
accountState = _config.Client.GetTvShowAccountState(BreakingBad).Result;
Assert.AreEqual(BreakingBad, accountState.Id);
accountState = _config.Client.GetTvShowAccountState(IdHelper.BreakingBad).Result;
Assert.AreEqual(IdHelper.BreakingBad, accountState.Id);
Assert.IsTrue(accountState.Rating.HasValue);
// Remove the rating
Assert.IsTrue(_config.Client.TvShowRemoveRating(BreakingBad).Result);
Assert.IsTrue(_config.Client.TvShowRemoveRating(IdHelper.BreakingBad).Result);
}
[TestMethod]
public void TestTvShowSetRatingBadRating()
{
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
Assert.IsFalse(_config.Client.TvShowSetRating(BreakingBad, 7.1).Result);
Assert.IsFalse(_config.Client.TvShowSetRating(IdHelper.BreakingBad, 7.1).Result);
}
[TestMethod]
public void TestTvShowSetRatingRatingOutOfBounds()
{
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
Assert.IsFalse(_config.Client.TvShowSetRating(BreakingBad, 10.5).Result);
Assert.IsFalse(_config.Client.TvShowSetRating(IdHelper.BreakingBad, 10.5).Result);
}
[TestMethod]
public void TestTvShowSetRatingRatingLowerBoundsTest()
{
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
Assert.IsFalse(_config.Client.TvShowSetRating(BreakingBad, 0).Result);
Assert.IsFalse(_config.Client.TvShowSetRating(IdHelper.BreakingBad, 0).Result);
}
[TestMethod]
public void TestTvShowSetRatingUserSession()
{
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
AccountState accountState = _config.Client.GetTvShowAccountState(BreakingBad).Result;
AccountState accountState = _config.Client.GetTvShowAccountState(IdHelper.BreakingBad).Result;
// Remove the rating
if (accountState.Rating.HasValue)
{
Assert.IsTrue(_config.Client.TvShowRemoveRating(BreakingBad).Result);
Assert.IsTrue(_config.Client.TvShowRemoveRating(IdHelper.BreakingBad).Result);
// Allow TMDb to cache our changes
Thread.Sleep(2000);
}
// Test that the episode is NOT rated
accountState = _config.Client.GetTvShowAccountState(BreakingBad).Result;
accountState = _config.Client.GetTvShowAccountState(IdHelper.BreakingBad).Result;
Assert.AreEqual(BreakingBad, accountState.Id);
Assert.AreEqual(IdHelper.BreakingBad, accountState.Id);
Assert.IsFalse(accountState.Rating.HasValue);
// Rate the episode
_config.Client.TvShowSetRating(BreakingBad, 5).Wait();
_config.Client.TvShowSetRating(IdHelper.BreakingBad, 5).Wait();
// Allow TMDb to cache our changes
Thread.Sleep(2000);
// Test that the episode IS rated
accountState = _config.Client.GetTvShowAccountState(BreakingBad).Result;
Assert.AreEqual(BreakingBad, accountState.Id);
accountState = _config.Client.GetTvShowAccountState(IdHelper.BreakingBad).Result;
Assert.AreEqual(IdHelper.BreakingBad, accountState.Id);
Assert.IsTrue(accountState.Rating.HasValue);
// Remove the rating
Assert.IsTrue(_config.Client.TvShowRemoveRating(BreakingBad).Result);
Assert.IsTrue(_config.Client.TvShowRemoveRating(IdHelper.BreakingBad).Result);
}
[TestMethod]
@ -563,10 +559,10 @@ namespace TMDbLibTests
_config.Client.SetSessionInformation(_config.GuestTestSessionId, SessionType.GuestSession);
// Try changing the rating
Assert.IsTrue(_config.Client.TvShowSetRating(BreakingBad, 7.5).Result);
Assert.IsTrue(_config.Client.TvShowSetRating(IdHelper.BreakingBad, 7.5).Result);
// Try changing it back to the previous rating
Assert.IsTrue(_config.Client.TvShowSetRating(BreakingBad, 8).Result);
Assert.IsTrue(_config.Client.TvShowSetRating(IdHelper.BreakingBad, 8).Result);
}
//[TestMethod]

View File

@ -0,0 +1,50 @@
namespace TMDbLibTests.Helpers
{
public static class IdHelper
{
// Movies
public const int Avatar = 19995;
public const int AGoodDayToDieHard = 47964;
public const int TheDarkKnightRises = 49026;
public const int MadMaxFuryRoad = 76341;
public const string AGoodDayToDieHardImdb = "tt1606378";
public const string TheDarkKnightRisesImdb = "tt1345836";
public const int Terminator = 218;
public const int EvanAlmighty = 2698;
public const string TheDarkKnightRisesReviewId = "5010553819c2952d1b000451";
public const int tmdbTerminatorId = 218;
public const string imdbTerminatorId = "tt0088247";
// TV
public const int BreakingBad = 1396;
public const int BreakingBadSeason1Id = 3572;
public const int BreakingBadSeason1Episode1Id = 62085;
public const int BigBangTheory = 1418;
public const int DoctorWho = 121;
public const int House = 1408;
public const int TmdbBreakingBadId = 1396;
public const string TvdbBreakingBadId = "81189";
public const string ImdbBreakingBadId = "tt0903747";
public const string TvRageBreakingBadId = "18164";
public const string FreebaseBreakingBadId = "en/breaking_bad";
public const string FreebaseMidBreakingBadId = "m/03d34x8";
// Persons
public const int BruceWillis = 62;
// Collections
public const int JamesBondCollection = 645;
// Networks
public const int TwentiethCenturyFox = 25;
public const int ColumbiaPictures = 5;
public const int Hbo = 49;
// Credits
public const string BruceWillisMiamiVice = "525719bb760ee3776a1835d3";
public const string HughLaurieHouse = "5256ccf519c2956ff607ca00";
}
}

View File

@ -76,6 +76,7 @@
<Compile Include="ClientCollectionTests.cs" />
<Compile Include="ClientSearchTests.cs" />
<Compile Include="ClientJobTests.cs" />
<Compile Include="Helpers\IdHelper.cs" />
<Compile Include="Helpers\TestImagesHelpers.cs" />
<Compile Include="Helpers\TestHelpers.cs" />
<Compile Include="TestClasses\EnumTestEnum.cs" />