Skip to content

Commit

Permalink
GH-125: Change tests for person movie credits objects
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikfroehling committed Mar 5, 2020
1 parent ca1255b commit 88765d3
Show file tree
Hide file tree
Showing 4 changed files with 242 additions and 3,117 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace TraktNet.Objects.Get.Tests.People.Credits.Implementations
{
using FluentAssertions;
using System;
using System.Threading.Tasks;
using Trakt.NET.Tests.Utility.Traits;
using TraktNet.Objects.Get.People.Credits;
Expand All @@ -17,6 +16,7 @@ public void Test_TraktPersonMovieCreditsCastItem_Default_Constructor()
var creditsCastItem = new TraktPersonMovieCreditsCastItem();

creditsCastItem.Character.Should().BeNullOrEmpty();
creditsCastItem.Characters.Should().BeNullOrEmpty();
creditsCastItem.Movie.Should().BeNull();
}

Expand All @@ -28,6 +28,7 @@ public async Task Test_TraktPersonMovieCreditsCastItem_From_Minimal_Json()

creditsCastItem.Should().NotBeNull();
creditsCastItem.Character.Should().Be("Joe Brody");
creditsCastItem.Characters.Should().NotBeNull().And.HaveCount(1).And.Contain("Joe Brody");
creditsCastItem.Movie.Should().NotBeNull();
creditsCastItem.Movie.Title.Should().Be("Star Wars: The Force Awakens");
creditsCastItem.Movie.Year.Should().Be(2015);
Expand All @@ -51,40 +52,12 @@ public async Task Test_TraktPersonMovieCreditsCastItem_From_Minimal_Json()
creditsCastItem.Movie.Certification.Should().BeNullOrEmpty();
}

[Fact]
public async Task Test_TraktPersonMovieCreditsCastItem_From_Full_Json()
{
var jsonReader = new PersonMovieCreditsCastItemObjectJsonReader();
var creditsCastItem = await jsonReader.ReadObjectAsync(FULL_JSON) as TraktPersonMovieCreditsCastItem;

creditsCastItem.Should().NotBeNull();
creditsCastItem.Character.Should().Be("Joe Brody");
creditsCastItem.Movie.Should().NotBeNull();
creditsCastItem.Movie.Title.Should().Be("Star Wars: The Force Awakens");
creditsCastItem.Movie.Year.Should().Be(2015);
creditsCastItem.Movie.Ids.Should().NotBeNull();
creditsCastItem.Movie.Ids.Trakt.Should().Be(94024U);
creditsCastItem.Movie.Ids.Slug.Should().Be("star-wars-the-force-awakens-2015");
creditsCastItem.Movie.Ids.Imdb.Should().Be("tt2488496");
creditsCastItem.Movie.Ids.Tmdb.Should().Be(140607U);
creditsCastItem.Movie.Tagline.Should().Be("Every generation has a story.");
creditsCastItem.Movie.Overview.Should().Be("Thirty years after defeating the Galactic Empire, Han Solo and his allies face a new threat from the evil Kylo Ren and his army of Stormtroopers.");
creditsCastItem.Movie.Released.Should().Be(DateTime.Parse("2015-12-18"));
creditsCastItem.Movie.Runtime.Should().Be(136);
creditsCastItem.Movie.UpdatedAt.Should().Be(DateTime.Parse("2016-03-31T09:01:59Z").ToUniversalTime());
creditsCastItem.Movie.Trailer.Should().Be("http://youtube.com/watch?v=uwa7N0ShN2U");
creditsCastItem.Movie.Homepage.Should().Be("http://www.starwars.com/films/star-wars-episode-vii");
creditsCastItem.Movie.Rating.Should().Be(8.31988f);
creditsCastItem.Movie.Votes.Should().Be(9338);
creditsCastItem.Movie.LanguageCode.Should().Be("en");
creditsCastItem.Movie.AvailableTranslationLanguageCodes.Should().NotBeNull().And.HaveCount(4).And.Contain("en", "de", "en", "it");
creditsCastItem.Movie.Genres.Should().NotBeNull().And.HaveCount(4).And.Contain("action", "adventure", "fantasy", "science-fiction");
creditsCastItem.Movie.Certification.Should().Be("PG-13");
}

private const string MINIMAL_JSON =
@"{
""character"": ""Joe Brody"",
""characters"": [
""Joe Brody""
],
""movie"": {
""title"": ""Star Wars: The Force Awakens"",
""year"": 2015,
Expand All @@ -96,43 +69,5 @@ public async Task Test_TraktPersonMovieCreditsCastItem_From_Full_Json()
}
}
}";

private const string FULL_JSON =
@"{
""character"": ""Joe Brody"",
""movie"": {
""title"": ""Star Wars: The Force Awakens"",
""year"": 2015,
""ids"": {
""trakt"": 94024,
""slug"": ""star-wars-the-force-awakens-2015"",
""imdb"": ""tt2488496"",
""tmdb"": 140607
},
""tagline"": ""Every generation has a story."",
""overview"": ""Thirty years after defeating the Galactic Empire, Han Solo and his allies face a new threat from the evil Kylo Ren and his army of Stormtroopers."",
""released"": ""2015-12-18"",
""runtime"": 136,
""trailer"": ""http://youtube.com/watch?v=uwa7N0ShN2U"",
""homepage"": ""http://www.starwars.com/films/star-wars-episode-vii"",
""rating"": 8.31988,
""votes"": 9338,
""updated_at"": ""2016-03-31T09:01:59Z"",
""language"": ""en"",
""available_translations"": [
""en"",
""de"",
""en"",
""it""
],
""genres"": [
""action"",
""adventure"",
""fantasy"",
""science-fiction""
],
""certification"": ""PG-13""
}
}";
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace TraktNet.Objects.Get.Tests.People.Credits.Implementations
{
using FluentAssertions;
using System;
using System.Threading.Tasks;
using Trakt.NET.Tests.Utility.Traits;
using TraktNet.Objects.Get.People.Credits;
Expand All @@ -17,6 +16,7 @@ public void Test_TraktPersonMovieCreditsCrewItem_Default_Constructor()
var creditsCrewItem = new TraktPersonMovieCreditsCrewItem();

creditsCrewItem.Job.Should().BeNullOrEmpty();
creditsCrewItem.Jobs.Should().BeNullOrEmpty();
creditsCrewItem.Movie.Should().BeNull();
}

Expand All @@ -28,6 +28,7 @@ public async Task Test_TraktPersonMovieCreditsCrewItem_From_Minimal_Json()

creditsCrewItem.Should().NotBeNull();
creditsCrewItem.Job.Should().Be("Director");
creditsCrewItem.Jobs.Should().NotBeNull().And.HaveCount(1).And.Contain("Director");
creditsCrewItem.Movie.Should().NotBeNull();
creditsCrewItem.Movie.Title.Should().Be("Star Wars: The Force Awakens");
creditsCrewItem.Movie.Year.Should().Be(2015);
Expand All @@ -51,40 +52,12 @@ public async Task Test_TraktPersonMovieCreditsCrewItem_From_Minimal_Json()
creditsCrewItem.Movie.Certification.Should().BeNullOrEmpty();
}

[Fact]
public async Task Test_TraktPersonMovieCreditsCrewItem_From_Full_Json()
{
var jsonReader = new PersonMovieCreditsCrewItemObjectJsonReader();
var creditsCrewItem = await jsonReader.ReadObjectAsync(FULL_JSON) as TraktPersonMovieCreditsCrewItem;

creditsCrewItem.Should().NotBeNull();
creditsCrewItem.Job.Should().Be("Director");
creditsCrewItem.Movie.Should().NotBeNull();
creditsCrewItem.Movie.Title.Should().Be("Star Wars: The Force Awakens");
creditsCrewItem.Movie.Year.Should().Be(2015);
creditsCrewItem.Movie.Ids.Should().NotBeNull();
creditsCrewItem.Movie.Ids.Trakt.Should().Be(94024U);
creditsCrewItem.Movie.Ids.Slug.Should().Be("star-wars-the-force-awakens-2015");
creditsCrewItem.Movie.Ids.Imdb.Should().Be("tt2488496");
creditsCrewItem.Movie.Ids.Tmdb.Should().Be(140607U);
creditsCrewItem.Movie.Tagline.Should().Be("Every generation has a story.");
creditsCrewItem.Movie.Overview.Should().Be("Thirty years after defeating the Galactic Empire, Han Solo and his allies face a new threat from the evil Kylo Ren and his army of Stormtroopers.");
creditsCrewItem.Movie.Released.Should().Be(DateTime.Parse("2015-12-18"));
creditsCrewItem.Movie.Runtime.Should().Be(136);
creditsCrewItem.Movie.UpdatedAt.Should().Be(DateTime.Parse("2016-03-31T09:01:59Z").ToUniversalTime());
creditsCrewItem.Movie.Trailer.Should().Be("http://youtube.com/watch?v=uwa7N0ShN2U");
creditsCrewItem.Movie.Homepage.Should().Be("http://www.starwars.com/films/star-wars-episode-vii");
creditsCrewItem.Movie.Rating.Should().Be(8.31988f);
creditsCrewItem.Movie.Votes.Should().Be(9338);
creditsCrewItem.Movie.LanguageCode.Should().Be("en");
creditsCrewItem.Movie.AvailableTranslationLanguageCodes.Should().NotBeNull().And.HaveCount(4).And.Contain("en", "de", "en", "it");
creditsCrewItem.Movie.Genres.Should().NotBeNull().And.HaveCount(4).And.Contain("action", "adventure", "fantasy", "science-fiction");
creditsCrewItem.Movie.Certification.Should().Be("PG-13");
}

private const string MINIMAL_JSON =
@"{
""job"": ""Director"",
""jobs"": [
""Director""
],
""movie"": {
""title"": ""Star Wars: The Force Awakens"",
""year"": 2015,
Expand All @@ -96,43 +69,5 @@ public async Task Test_TraktPersonMovieCreditsCrewItem_From_Full_Json()
}
}
}";

private const string FULL_JSON =
@"{
""job"": ""Director"",
""movie"": {
""title"": ""Star Wars: The Force Awakens"",
""year"": 2015,
""ids"": {
""trakt"": 94024,
""slug"": ""star-wars-the-force-awakens-2015"",
""imdb"": ""tt2488496"",
""tmdb"": 140607
},
""tagline"": ""Every generation has a story."",
""overview"": ""Thirty years after defeating the Galactic Empire, Han Solo and his allies face a new threat from the evil Kylo Ren and his army of Stormtroopers."",
""released"": ""2015-12-18"",
""runtime"": 136,
""trailer"": ""http://youtube.com/watch?v=uwa7N0ShN2U"",
""homepage"": ""http://www.starwars.com/films/star-wars-episode-vii"",
""rating"": 8.31988,
""votes"": 9338,
""updated_at"": ""2016-03-31T09:01:59Z"",
""language"": ""en"",
""available_translations"": [
""en"",
""de"",
""en"",
""it""
],
""genres"": [
""action"",
""adventure"",
""fantasy"",
""science-fiction""
],
""certification"": ""PG-13""
}
}";
}
}
Loading

0 comments on commit 88765d3

Please sign in to comment.