mirror of
https://github.com/jellyfin/TMDbLib.git
synced 2024-11-26 23:30:23 +00:00
- Extend images testing / refactor it
- Discovered that the Persons API doesn't accept languages (explains a few things too) - Added test for issue #1 - Fixed issue #1 - Fixed a test for Changes - Upgraded to version 0.7.3
This commit is contained in:
parent
4474493645
commit
b636010cf9
@ -35,23 +35,26 @@ namespace TMDbLib.Client
|
||||
IRestResponse<Movie> resp = _client.Get<Movie>(req);
|
||||
|
||||
// Patch up data, so that the end user won't notice that we share objects between request-types.
|
||||
if (resp.Data.Trailers != null)
|
||||
resp.Data.Trailers.Id = resp.Data.Id;
|
||||
if (resp.Data != null)
|
||||
{
|
||||
if (resp.Data.Trailers != null)
|
||||
resp.Data.Trailers.Id = resp.Data.Id;
|
||||
|
||||
if (resp.Data.AlternativeTitles != null)
|
||||
resp.Data.AlternativeTitles.Id = resp.Data.Id;
|
||||
if (resp.Data.AlternativeTitles != null)
|
||||
resp.Data.AlternativeTitles.Id = resp.Data.Id;
|
||||
|
||||
if (resp.Data.Casts != null)
|
||||
resp.Data.Casts.Id = resp.Data.Id;
|
||||
if (resp.Data.Casts != null)
|
||||
resp.Data.Casts.Id = resp.Data.Id;
|
||||
|
||||
if (resp.Data.Releases != null)
|
||||
resp.Data.Releases.Id = resp.Data.Id;
|
||||
if (resp.Data.Releases != null)
|
||||
resp.Data.Releases.Id = resp.Data.Id;
|
||||
|
||||
if (resp.Data.Keywords != null)
|
||||
resp.Data.Keywords.Id = resp.Data.Id;
|
||||
if (resp.Data.Keywords != null)
|
||||
resp.Data.Keywords.Id = resp.Data.Id;
|
||||
|
||||
if (resp.Data.Translations != null)
|
||||
resp.Data.Translations.Id = resp.Data.Id;
|
||||
if (resp.Data.Translations != null)
|
||||
resp.Data.Translations.Id = resp.Data.Id;
|
||||
}
|
||||
|
||||
return resp.Data;
|
||||
}
|
||||
|
@ -10,18 +10,10 @@ namespace TMDbLib.Client
|
||||
public partial class TMDbClient
|
||||
{
|
||||
public Person GetPerson(int id, PersonMethods extraMethods = PersonMethods.Undefined)
|
||||
{
|
||||
return GetPerson(id, DefaultLanguage, extraMethods);
|
||||
}
|
||||
|
||||
public Person GetPerson(int id, string language, PersonMethods extraMethods = PersonMethods.Undefined)
|
||||
{
|
||||
RestRequest req = new RestRequest("person/{id}");
|
||||
req.AddUrlSegment("id", id.ToString());
|
||||
|
||||
if (language != null)
|
||||
req.AddParameter("language", language);
|
||||
|
||||
string appends = string.Join(",",
|
||||
Enum.GetValues(typeof(PersonMethods))
|
||||
.OfType<PersonMethods>()
|
||||
@ -37,11 +29,14 @@ namespace TMDbLib.Client
|
||||
IRestResponse<Person> resp = _client.Get<Person>(req);
|
||||
|
||||
// Patch up data, so that the end user won't notice that we share objects between request-types.
|
||||
if (resp.Data.Images != null)
|
||||
resp.Data.Images.Id = resp.Data.Id;
|
||||
if (resp.Data != null)
|
||||
{
|
||||
if (resp.Data.Images != null)
|
||||
resp.Data.Images.Id = resp.Data.Id;
|
||||
|
||||
if (resp.Data.Credits != null)
|
||||
resp.Data.Credits.Id = resp.Data.Id;
|
||||
if (resp.Data.Credits != null)
|
||||
resp.Data.Credits.Id = resp.Data.Id;
|
||||
}
|
||||
|
||||
return resp.Data;
|
||||
}
|
||||
|
@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
||||
// 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("0.7.2.0")]
|
||||
[assembly: AssemblyFileVersion("0.7.2.0")]
|
||||
[assembly: AssemblyVersion("0.7.3.0")]
|
||||
[assembly: AssemblyFileVersion("0.7.3.0")]
|
||||
|
@ -49,10 +49,6 @@ namespace TMDbLibTests
|
||||
Assert.IsNotNull(changesLowDate);
|
||||
Assert.AreEqual(1, changesLowDate.Page);
|
||||
Assert.AreNotEqual(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)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
@ -12,6 +12,7 @@ namespace TMDbLibTests
|
||||
public class ClientMovieTests
|
||||
{
|
||||
private const int AGoodDayToDieHard = 47964;
|
||||
private const int Avatar = 19995;
|
||||
|
||||
private Dictionary<MovieMethods, Func<Movie, object>> _methods;
|
||||
private TestConfig _config;
|
||||
@ -66,6 +67,14 @@ namespace TMDbLibTests
|
||||
TestMethodsHelper.TestGetAll(_methods, item);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMoviesNull()
|
||||
{
|
||||
Movie item = _config.Client.GetMovie(Avatar, "fr");
|
||||
|
||||
Assert.IsNull(item);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMoviesLanguage()
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using TMDbLib.Objects.General;
|
||||
@ -60,29 +61,6 @@ namespace TMDbLibTests
|
||||
TestMethodsHelper.TestGetAll(_methods, item);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestPersonsLanguage()
|
||||
{
|
||||
Person person = _config.Client.GetPerson(BruceWillis);
|
||||
Person personItalian = _config.Client.GetPerson(BruceWillis, "it");
|
||||
|
||||
Assert.IsNotNull(person);
|
||||
Assert.IsNotNull(personItalian);
|
||||
|
||||
Assert.AreEqual("Bruce Willis", person.Name);
|
||||
Assert.AreEqual("Bruce Willis", personItalian.Name);
|
||||
|
||||
// Test all extras, ensure none of them exist
|
||||
foreach (Func<Person, object> selector in _methods.Values)
|
||||
{
|
||||
Assert.IsNull(selector(person));
|
||||
Assert.IsNull(selector(personItalian));
|
||||
}
|
||||
|
||||
// Todo: Check language-specific items
|
||||
// Requires a person with alternate names.
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestPersonsGetPersonCredits()
|
||||
{
|
||||
@ -160,19 +138,7 @@ namespace TMDbLibTests
|
||||
Assert.AreEqual(BruceWillis, images.Id);
|
||||
Assert.IsTrue(images.Profiles.Count > 0);
|
||||
|
||||
List<string> profileSizes = _config.Client.Config.Images.ProfileSizes;
|
||||
|
||||
foreach (Profile profile in images.Profiles)
|
||||
{
|
||||
foreach (string size in profileSizes)
|
||||
{
|
||||
Uri url = _config.Client.GetImageUrl(size, profile.FilePath);
|
||||
Uri urlSecure = _config.Client.GetImageUrl(size, profile.FilePath, true);
|
||||
|
||||
Assert.IsTrue(TestHelpers.InternetUriExists(url));
|
||||
Assert.IsTrue(TestHelpers.InternetUriExists(urlSecure));
|
||||
}
|
||||
}
|
||||
TestImagesHelpers.TestImages(_config, images);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMDbLib.Objects.General;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System.Linq;
|
||||
using TMDbLib.Objects.Person;
|
||||
|
||||
namespace TMDbLibTests.Helpers
|
||||
{
|
||||
public static class TestImagesHelpers
|
||||
{
|
||||
public static void TestImages(TestConfig config, ProfileImages images)
|
||||
{
|
||||
Assert.IsTrue(images.Profiles.Count > 0);
|
||||
|
||||
string profileSize = config.Client.Config.Images.ProfileSizes.First();
|
||||
|
||||
TestImagesInternal(config, images.Profiles.Select(s => s.FilePath), profileSize);
|
||||
}
|
||||
|
||||
public static void TestImages(TestConfig config, Images images)
|
||||
{
|
||||
Assert.IsTrue(images.Backdrops.Count > 0);
|
||||
Assert.IsTrue(images.Posters.Count > 0);
|
||||
|
||||
string backdropSizes = config.Client.Config.Images.BackdropSizes.First();
|
||||
string posterSizes = config.Client.Config.Images.PosterSizes.First();
|
||||
string backdropSize = config.Client.Config.Images.BackdropSizes.First();
|
||||
string posterSize = config.Client.Config.Images.PosterSizes.First();
|
||||
|
||||
foreach (ImageData imageData in images.Backdrops)
|
||||
TestImagesInternal(config, images.Backdrops.Select(s => s.FilePath), backdropSize);
|
||||
|
||||
TestImagesInternal(config, images.Posters.Select(s => s.FilePath), posterSize);
|
||||
}
|
||||
|
||||
private static void TestImagesInternal(TestConfig config, IEnumerable<string> images, string posterSize)
|
||||
{
|
||||
foreach (string imageData in images)
|
||||
{
|
||||
Uri url = config.Client.GetImageUrl(backdropSizes, imageData.FilePath);
|
||||
Uri urlSecure = config.Client.GetImageUrl(backdropSizes, imageData.FilePath, true);
|
||||
|
||||
Assert.IsTrue(TestHelpers.InternetUriExists(url));
|
||||
Assert.IsTrue(TestHelpers.InternetUriExists(urlSecure));
|
||||
}
|
||||
|
||||
foreach (ImageData imageData in images.Posters)
|
||||
{
|
||||
Uri url = config.Client.GetImageUrl(posterSizes, imageData.FilePath);
|
||||
Uri urlSecure = config.Client.GetImageUrl(posterSizes, imageData.FilePath, true);
|
||||
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));
|
||||
|
Loading…
Reference in New Issue
Block a user