-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* get recommended and similar movies (#45) * get recommended and similar movies * make necessary changes * Fix formatting and whitespace. This follows the repo's already defined code styles. * Shore up the tests for movie recommendations. Add more tests for MovieInfo in the util. * Discover movies (#46) * create discover request api * create discover movie parameter builders * indentation changes * test discover movies * seperate movie parameter builder * remove extra lines and add new line * add editor config file Co-authored-by: Barış Can YILMAZ <baris@bariscanyilmaz> Co-authored-by: kindler chase <[email protected]> * Fix formatting and whitespace. This follows the repo's already defined code styles. * Fix class name spelling error. * Add error checking in DiscoverMoviesAsync. Add error checking in DiscoverMoviesAsync; update conventions to follow repo conventions. * Fix spelling error in method name. * Delete unneeded parameter builder; should be on the main interface. * Update method name for clarity. * Clean up parameter builder with reusable method. * Improve discover movie tests. Improve discover movie tests. * Use the response util to validate results. * Follow conventions of repo styles * Fix copy/paste variable names to be correct names. * Fix method names to reflect actual intent. * Set the default date converter with Epoch time as default date. Set the default date converter with Epoch time as default date. Sometimes the MovieInfo json is missing the release date, so add the expected pre-defined value as the default value. * Modify ApiRequestBase to set the default json serialization settings. Modify ApiRequestBase to set the default json serialization settings. This is a one time operation that all deserialization will use. Clean up the overloads a bit as well. * Add documentation to the IApiDiscoverRequest; update param name. * Fix broken test due to new IApiDiscoverRequest. * Fix broken integration test. Fix broken integration test. Apparently Milla is no longer known for zoolander. * Fix integration test for correct updated count for IApiRequest objects. * Prefer arrays over lists. * Improve GetSimilar tests. * Simplify AssertCanPageSearchResponse. Simplify AssertCanPageSearchResponse. No need to keep track of every single search result duplicated; just need to track the overall duplicate results. * Show duplicate results for GetSimilarAsync_CanPage. Lower dup threshold. * Write to the Trace instead of Debug. * Simplify AssertCanPageSearchResponse by removing min total results param. Simplify AssertCanPageSearchResponse by removing min total results param. The api always returns results with a page size of 20. Just calc the expected size in the util and not as a param. Co-authored-by: Barış Can Yılmaz <[email protected]> Co-authored-by: Barış Can YILMAZ <baris@bariscanyilmaz>
- Loading branch information
1 parent
0cd724a
commit d543d98
Showing
21 changed files
with
637 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
DM.MovieApi.IntegrationTests/MovieDb/Discover/ApiDiscoverRequestTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using DM.MovieApi.ApiResponse; | ||
using DM.MovieApi.MovieDb.Discover; | ||
using DM.MovieApi.MovieDb.Movies; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace DM.MovieApi.IntegrationTests.MovieDb.Discover | ||
{ | ||
[TestClass] | ||
public class ApiDiscoverRequestTests | ||
{ | ||
private IApiDiscoverRequest _api; | ||
|
||
[TestInitialize] | ||
public void TestInit() | ||
{ | ||
ApiResponseUtil.ThrottleTests(); | ||
|
||
_api = MovieDbFactory.Create<IApiDiscoverRequest>().Value; | ||
|
||
Assert.IsInstanceOfType( _api, typeof( ApiDiscoverRequest ) ); | ||
} | ||
|
||
[TestMethod] | ||
public async Task DiscoverMovies_WithCrew() | ||
{ | ||
int directorId = 66212; | ||
|
||
IDiscoverMovieParameterBuilder builder = CreateBuilder(); | ||
builder.WithCrew( directorId ); | ||
|
||
ApiSearchResponse<MovieInfo> response = await _api.DiscoverMoviesAsync( builder ); | ||
|
||
ApiResponseUtil.AssertErrorIsNull( response ); | ||
ApiResponseUtil.AssertMovieInformationStructure( response.Results ); | ||
} | ||
|
||
[TestMethod] | ||
public async Task DiscoverMovies_WithCrew_HasNoResult_InvalidPersonId() | ||
{ | ||
int personId = 0; | ||
|
||
IDiscoverMovieParameterBuilder builder = CreateBuilder(); | ||
builder.WithCrew( personId ); | ||
|
||
ApiSearchResponse<MovieInfo> response = await _api.DiscoverMoviesAsync( builder ); | ||
|
||
ApiResponseUtil.AssertNoSearchResults( response ); | ||
} | ||
|
||
[TestMethod] | ||
public async Task DiscoverMovies_WithCast() | ||
{ | ||
int actorId = 66462; | ||
|
||
IDiscoverMovieParameterBuilder builder = CreateBuilder(); | ||
builder.WithCast( actorId ); | ||
|
||
ApiSearchResponse<MovieInfo> response = await _api.DiscoverMoviesAsync( builder ); | ||
|
||
ApiResponseUtil.AssertErrorIsNull( response ); | ||
ApiResponseUtil.AssertMovieInformationStructure( response.Results ); | ||
} | ||
|
||
[TestMethod] | ||
public async Task DiscoverMovies_WithCast_HasNoResult_InvalidPersonId() | ||
{ | ||
int personId = 0; | ||
|
||
IDiscoverMovieParameterBuilder builder = CreateBuilder(); | ||
builder.WithCast( personId ); | ||
|
||
ApiSearchResponse<MovieInfo> response = await _api.DiscoverMoviesAsync( builder ); | ||
|
||
ApiResponseUtil.AssertNoSearchResults( response ); | ||
} | ||
|
||
[TestMethod] | ||
public async Task DiscoverMovies_WithGenre() | ||
{ | ||
int genreId = 28; | ||
|
||
IDiscoverMovieParameterBuilder builder = CreateBuilder(); | ||
builder.WithGenre( genreId ); | ||
|
||
ApiSearchResponse<MovieInfo> response = await _api.DiscoverMoviesAsync( builder ); | ||
|
||
ApiResponseUtil.AssertErrorIsNull( response ); | ||
ApiResponseUtil.AssertMovieInformationStructure( response.Results ); | ||
|
||
Assert.IsTrue( response.Results | ||
.All( r => r.Genres.Any( g => g.Id == genreId ) ), "No results with genre" ); | ||
} | ||
|
||
[TestMethod] | ||
public async Task DiscoverMovies_ExcludeGenre() | ||
{ | ||
int genreId = 28; | ||
|
||
IDiscoverMovieParameterBuilder builder = CreateBuilder(); | ||
builder.ExcludeGenre( genreId ); | ||
|
||
ApiSearchResponse<MovieInfo> response = await _api.DiscoverMoviesAsync( builder ); | ||
|
||
ApiResponseUtil.AssertErrorIsNull( response ); | ||
ApiResponseUtil.AssertMovieInformationStructure( response.Results ); | ||
|
||
Assert.IsTrue( response.Results | ||
.All( r => r.Genres.All( g => g.Id != genreId ) ), "Genre found in results" ); | ||
} | ||
|
||
[TestMethod] | ||
public async Task DiscoverMovies_WithOriginalLanguage_InFinnish() | ||
{ | ||
int directorId = 66212; | ||
string originalLanguage = "fi"; | ||
|
||
IDiscoverMovieParameterBuilder builder = CreateBuilder(); | ||
builder.WithOriginalLanguage( originalLanguage ).WithCrew( directorId ); | ||
|
||
ApiSearchResponse<MovieInfo> response = await _api.DiscoverMoviesAsync( builder ); | ||
|
||
ApiResponseUtil.AssertErrorIsNull( response ); | ||
ApiResponseUtil.AssertMovieInformationStructure( response.Results ); | ||
} | ||
|
||
[TestMethod] | ||
public async Task DiscoverMovies_WithOriginalLanguage_InGerman() | ||
{ | ||
int directorId = 66212; | ||
string originalLanguage = "de"; | ||
|
||
IDiscoverMovieParameterBuilder builder = CreateBuilder(); | ||
builder.WithOriginalLanguage( originalLanguage ).WithCrew( directorId ); | ||
|
||
ApiSearchResponse<MovieInfo> response = await _api.DiscoverMoviesAsync( builder ); | ||
|
||
ApiResponseUtil.AssertErrorIsNull( response ); | ||
ApiResponseUtil.AssertMovieInformationStructure( response.Results ); | ||
} | ||
|
||
private IDiscoverMovieParameterBuilder CreateBuilder() | ||
=> new DiscoverMovieParameterBuilder(); | ||
} | ||
} |
Oops, something went wrong.