Skip to content

Commit

Permalink
GH-452: Add additional argument checks
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikfroehling committed Jul 28, 2023
1 parent 43c3f9d commit e8cc6a0
Show file tree
Hide file tree
Showing 64 changed files with 192 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ public Task<TraktResponse<ITraktEpisode>> GetEpisodeAsync(ITraktShowIds showIds,
if (showIds == null)
throw new ArgumentNullException(nameof(showIds));

if (!showIds.HasAnyId)
throw new ArgumentException($"{nameof(showIds)} has not any ids set", nameof(showIds));

return GetEpisodeImplementationAsync(false, showIds.GetBestId(), seasonNumber, episodeNumber, extendedInfo, cancellationToken);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ public Task<TraktPagedResponse<ITraktComment>> GetEpisodeCommentsAsync(ITraktSho
if (showIds == null)
throw new ArgumentNullException(nameof(showIds));

if (!showIds.HasAnyId)
throw new ArgumentException($"{nameof(showIds)} has not any ids set", nameof(showIds));

return GetEpisodeCommentsAsync(showIds.GetBestId(), seasonNumber, episodeNumber, commentSortOrder,
extendedInfo, pagedParameters, cancellationToken);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ public Task<TraktPagedResponse<ITraktList>> GetEpisodeListsAsync(ITraktShowIds s
if (showIds == null)
throw new ArgumentNullException(nameof(showIds));

if (!showIds.HasAnyId)
throw new ArgumentException($"{nameof(showIds)} has not any ids set", nameof(showIds));

return GetEpisodeListsAsync(showIds.GetBestId(), seasonNumber, episodeNumber, listType, listSortOrder,
extendedInfo, pagedParameters, cancellationToken);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ public Task<TraktResponse<ITraktShowCastAndCrew>> GetEpisodePeopleAsync(ITraktSh
if (showIds == null)
throw new ArgumentNullException(nameof(showIds));

if (!showIds.HasAnyId)
throw new ArgumentException($"{nameof(showIds)} has not any ids set", nameof(showIds));

return GetEpisodePeopleAsync(showIds.GetBestId(), seasonNumber, episodeNumber, extendedInfo, cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ public Task<TraktResponse<ITraktRating>> GetEpisodeRatingsAsync(ITraktShowIds sh
if (showIds == null)
throw new ArgumentNullException(nameof(showIds));

if (!showIds.HasAnyId)
throw new ArgumentException($"{nameof(showIds)} has not any ids set", nameof(showIds));

return GetEpisodeRatingsAsync(showIds.GetBestId(), seasonNumber, episodeNumber, cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ public Task<TraktResponse<ITraktStatistics>> GetEpisodeStatisticsAsync(ITraktSho
if (showIds == null)
throw new ArgumentNullException(nameof(showIds));

if (!showIds.HasAnyId)
throw new ArgumentException($"{nameof(showIds)} has not any ids set", nameof(showIds));

return GetEpisodeStatisticsAsync(showIds.GetBestId(), seasonNumber, episodeNumber, cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ public Task<TraktListResponse<ITraktEpisodeTranslation>> GetEpisodeTranslationsA
if (showIds == null)
throw new ArgumentNullException(nameof(showIds));

if (!showIds.HasAnyId)
throw new ArgumentException($"{nameof(showIds)} has not any ids set", nameof(showIds));

return GetEpisodeTranslationsAsync(showIds.GetBestId(), seasonNumber, episodeNumber, languageCode, cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ public Task<TraktListResponse<ITraktUser>> GetEpisodeWatchingUsersAsync(ITraktSh
if (showIds == null)
throw new ArgumentNullException(nameof(showIds));

if (!showIds.HasAnyId)
throw new ArgumentException($"{nameof(showIds)} has not any ids set", nameof(showIds));

return GetEpisodeWatchingUsersAsync(showIds.GetBestId(), seasonNumber, episodeNumber, extendedInfo, cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ public Task<TraktPagedResponse<ITraktComment>> GetListCommentsAsync(ITraktListId
if (listIds == null)
throw new ArgumentNullException(nameof(listIds));

if (!listIds.HasAnyId)
throw new ArgumentException($"{nameof(listIds)} has not any ids set", nameof(listIds));

return GetListCommentsAsync(listIds.GetBestId(), commentSortOrder, extendedInfo, pagedParameters, cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ public Task<TraktResponse<ITraktList>> GetListAsync(ITraktListIds listIds, Trakt
if (listIds == null)
throw new ArgumentNullException(nameof(listIds));

if (!listIds.HasAnyId)
throw new ArgumentException($"{nameof(listIds)} has not any ids set", nameof(listIds));

return GetListAsync(listIds.GetBestId(), extendedInfo, cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ public Task<TraktPagedResponse<ITraktListItem>> GetListItemsAsync(ITraktListIds
if (listIds == null)
throw new ArgumentNullException(nameof(listIds));

if (!listIds.HasAnyId)
throw new ArgumentException($"{nameof(listIds)} has not any ids set", nameof(listIds));

return GetListItemsAsync(listIds.GetBestId(), listItemType, extendedInfo, pagedParameters, cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ public Task<TraktPagedResponse<ITraktListLike>> GetListLikesAsync(ITraktListIds
if (listIds == null)
throw new ArgumentNullException(nameof(listIds));

if (!listIds.HasAnyId)
throw new ArgumentException($"{nameof(listIds)} has not any ids set", nameof(listIds));

return GetListLikesAsync(listIds.GetBestId(), extendedInfo, pagedParameters, cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ public Task<TraktNoContentResponse> LikeListAsync(ITraktListIds listIds, Cancell
if (listIds == null)
throw new ArgumentNullException(nameof(listIds));

if (!listIds.HasAnyId)
throw new ArgumentException($"{nameof(listIds)} has not any ids set", nameof(listIds));

return LikeListAsync(listIds.GetBestId(), cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ public Task<TraktNoContentResponse> UnlikeListAsync(ITraktListIds listIds, Cance
if (listIds == null)
throw new ArgumentNullException(nameof(listIds));

if (!listIds.HasAnyId)
throw new ArgumentException($"{nameof(listIds)} has not any ids set", nameof(listIds));

return UnlikeListAsync(listIds.GetBestId(), cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ public Task<TraktResponse<ITraktMovie>> GetMovieAsync(ITraktMovieIds movieIds, T
if (movieIds == null)
throw new ArgumentNullException(nameof(movieIds));

if (!movieIds.HasAnyId)
throw new ArgumentException($"{nameof(movieIds)} has not any ids set", nameof(movieIds));

return GetMovieImplementationAsync(false, movieIds.GetBestId(), extendedInfo, cancellationToken);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public Task<TraktListResponse<ITraktMovieAlias>> GetMovieAliasesAsync(ITraktMovi
if (movieIds == null)
throw new ArgumentNullException(nameof(movieIds));

if (!movieIds.HasAnyId)
throw new ArgumentException($"{nameof(movieIds)} has not any ids set", nameof(movieIds));

return GetMovieAliasesAsync(movieIds.GetBestId(), cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ public Task<TraktPagedResponse<ITraktComment>> GetMovieCommentsAsync(ITraktMovie
if (movieIds == null)
throw new ArgumentNullException(nameof(movieIds));

if (!movieIds.HasAnyId)
throw new ArgumentException($"{nameof(movieIds)} has not any ids set", nameof(movieIds));

return GetMovieCommentsAsync(movieIds.GetBestId(), commentSortOrder, extendedInfo, pagedParameters, cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ public Task<TraktPagedResponse<ITraktList>> GetMovieListsAsync(ITraktMovieIds mo
if (movieIds == null)
throw new ArgumentNullException(nameof(movieIds));

if (!movieIds.HasAnyId)
throw new ArgumentException($"{nameof(movieIds)} has not any ids set", nameof(movieIds));

return GetMovieListsAsync(movieIds.GetBestId(), listType, listSortOrder, extendedInfo, pagedParameters, cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ public Task<TraktResponse<ITraktCastAndCrew>> GetMoviePeopleAsync(ITraktMovieIds
if (movieIds == null)
throw new ArgumentNullException(nameof(movieIds));

if (!movieIds.HasAnyId)
throw new ArgumentException($"{nameof(movieIds)} has not any ids set", nameof(movieIds));

return GetMoviePeopleAsync(movieIds.GetBestId(), extendedInfo, cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ public Task<TraktResponse<ITraktRating>> GetMovieRatingsAsync(ITraktMovieIds mov
if (movieIds == null)
throw new ArgumentNullException(nameof(movieIds));

if (!movieIds.HasAnyId)
throw new ArgumentException($"{nameof(movieIds)} has not any ids set", nameof(movieIds));

return GetMovieRatingsAsync(movieIds.GetBestId(), cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ public Task<TraktPagedResponse<ITraktMovie>> GetMovieRelatedMoviesAsync(ITraktMo
if (movieIds == null)
throw new ArgumentNullException(nameof(movieIds));

if (!movieIds.HasAnyId)
throw new ArgumentException($"{nameof(movieIds)} has not any ids set", nameof(movieIds));

return GetMovieRelatedMoviesAsync(movieIds.GetBestId(), extendedInfo, pagedParameters, cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ public Task<TraktListResponse<ITraktMovieRelease>> GetMovieReleasesAsync(ITraktM
if (movieIds == null)
throw new ArgumentNullException(nameof(movieIds));

if (!movieIds.HasAnyId)
throw new ArgumentException($"{nameof(movieIds)} has not any ids set", nameof(movieIds));

return GetMovieReleasesAsync(movieIds.GetBestId(), countryCode, cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ public Task<TraktResponse<ITraktStatistics>> GetMovieStatisticsAsync(ITraktMovie
if (movieIds == null)
throw new ArgumentNullException(nameof(movieIds));

if (!movieIds.HasAnyId)
throw new ArgumentException($"{nameof(movieIds)} has not any ids set", nameof(movieIds));

return GetMovieStatisticsAsync(movieIds.GetBestId(), cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ public Task<TraktListResponse<ITraktStudio>> GetMovieStudiosAsync(ITraktMovieIds
if (movieIds == null)
throw new ArgumentNullException(nameof(movieIds));

if (!movieIds.HasAnyId)
throw new ArgumentException($"{nameof(movieIds)} has not any ids set", nameof(movieIds));

return GetMovieStudiosAsync(movieIds.GetBestId(), cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ public Task<TraktListResponse<ITraktMovieTranslation>> GetMovieTranslationsAsync
if (movieIds == null)
throw new ArgumentNullException(nameof(movieIds));

if (!movieIds.HasAnyId)
throw new ArgumentException($"{nameof(movieIds)} has not any ids set", nameof(movieIds));

return GetMovieTranslationsAsync(movieIds.GetBestId(), languageCode, cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ public Task<TraktListResponse<ITraktUser>> GetMovieWatchingUsersAsync(ITraktMovi
if (movieIds == null)
throw new ArgumentNullException(nameof(movieIds));

if (!movieIds.HasAnyId)
throw new ArgumentException($"{nameof(movieIds)} has not any ids set", nameof(movieIds));

return GetMovieWatchingUsersAsync(movieIds.GetBestId(), extendedInfo, cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ public Task<TraktResponse<ITraktPerson>> GetPersonAsync(ITraktPersonIds personId
if (personIds == null)
throw new ArgumentNullException(nameof(personIds));

if (!personIds.HasAnyId)
throw new ArgumentException($"{nameof(personIds)} has not any ids set", nameof(personIds));

return GetPersoImplementationAsync(false, personIds.GetBestId(), extendedInfo, cancellationToken);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ public Task<TraktPagedResponse<ITraktList>> GetPersonListsAsync(ITraktPersonIds
if (personIds == null)
throw new ArgumentNullException(nameof(personIds));

if (!personIds.HasAnyId)
throw new ArgumentException($"{nameof(personIds)} has not any ids set", nameof(personIds));

return GetPersonListsAsync(personIds.GetBestId(), listType, listSortOrder, extendedInfo, pagedParameters, cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ public Task<TraktResponse<ITraktPersonMovieCredits>> GetPersonMovieCreditsAsync(
if (personIds == null)
throw new ArgumentNullException(nameof(personIds));

if (!personIds.HasAnyId)
throw new ArgumentException($"{nameof(personIds)} has not any ids set", nameof(personIds));

return GetPersonMovieCreditsAsync(personIds.GetBestId(), extendedInfo, cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ public Task<TraktResponse<ITraktPersonShowCredits>> GetPersonShowCreditsAsync(IT
if (personIds == null)
throw new ArgumentNullException(nameof(personIds));

if (!personIds.HasAnyId)
throw new ArgumentException($"{nameof(personIds)} has not any ids set", nameof(personIds));

return GetPersonShowCreditsAsync(personIds.GetBestId(), extendedInfo, cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ public Task<TraktNoContentResponse> HideMovieRecommendationAsync(ITraktMovieIds
if (movieIds == null)
throw new ArgumentNullException(nameof(movieIds));

if (!movieIds.HasAnyId)
throw new ArgumentException($"{nameof(movieIds)} has not any ids set", nameof(movieIds));

return HideMovieRecommendationAsync(movieIds.GetBestId(), cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ public Task<TraktNoContentResponse> HideShowRecommendationAsync(ITraktShowIds sh
if (showIds == null)
throw new ArgumentNullException(nameof(showIds));

if (!showIds.HasAnyId)
throw new ArgumentException($"{nameof(showIds)} has not any ids set", nameof(showIds));

return HideShowRecommendationAsync(showIds.GetBestId(), cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,9 @@ public async Task Test_TraktEpisodesModule_GetEpisodeComments_Throws_ArgumentExc
Func<Task<TraktPagedResponse<ITraktComment>>> act = () => client.Episodes.GetEpisodeCommentsAsync(default(ITraktShowIds), SEASON_NR, EPISODE_NR);
await act.Should().ThrowAsync<ArgumentNullException>();

act = () => client.Episodes.GetEpisodeCommentsAsync(new TraktShowIds(), SEASON_NR, EPISODE_NR);
await act.Should().ThrowAsync<ArgumentException>();

act = () => client.Episodes.GetEpisodeCommentsAsync(0, SEASON_NR, EPISODE_NR);
await act.Should().ThrowAsync<ArgumentException>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,9 @@ public async Task Test_TraktEpisodesModule_GetEpisodeLists_Throws_ArgumentExcept
Func<Task<TraktPagedResponse<ITraktList>>> act = () => client.Episodes.GetEpisodeListsAsync(default(ITraktShowIds), SEASON_NR, EPISODE_NR);
await act.Should().ThrowAsync<ArgumentNullException>();

act = () => client.Episodes.GetEpisodeListsAsync(new TraktShowIds(), SEASON_NR, EPISODE_NR);
await act.Should().ThrowAsync<ArgumentException>();

act = () => client.Episodes.GetEpisodeListsAsync(0, SEASON_NR, EPISODE_NR);
await act.Should().ThrowAsync<ArgumentException>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ public async Task Test_TraktEpisodesModule_GetEpisodePeople_Throws_ArgumentExcep
Func<Task<TraktResponse<ITraktShowCastAndCrew>>> act = () => client.Episodes.GetEpisodePeopleAsync(default(ITraktShowIds), SEASON_NR, EPISODE_NR);
await act.Should().ThrowAsync<ArgumentNullException>();

act = () => client.Episodes.GetEpisodePeopleAsync(new TraktShowIds(), SEASON_NR, EPISODE_NR);
await act.Should().ThrowAsync<ArgumentException>();

act = () => client.Episodes.GetEpisodePeopleAsync(0, SEASON_NR, EPISODE_NR);
await act.Should().ThrowAsync<ArgumentException>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ public async Task Test_TraktEpisodesModule_GetEpisodeRatings_Throws_ArgumentExce
Func<Task<TraktResponse<ITraktRating>>> act = () => client.Episodes.GetEpisodeRatingsAsync(default(ITraktShowIds), SEASON_NR, EPISODE_NR);
await act.Should().ThrowAsync<ArgumentNullException>();

act = () => client.Episodes.GetEpisodeRatingsAsync(new TraktShowIds(), SEASON_NR, EPISODE_NR);
await act.Should().ThrowAsync<ArgumentException>();

act = () => client.Episodes.GetEpisodeRatingsAsync(0, SEASON_NR, EPISODE_NR);
await act.Should().ThrowAsync<ArgumentException>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ public async Task Test_TraktEpisodesModule_GetEpisodeStatistics_Throws_ArgumentE
Func<Task<TraktResponse<ITraktStatistics>>> act = () => client.Episodes.GetEpisodeStatisticsAsync(default(ITraktShowIds), SEASON_NR, EPISODE_NR);
await act.Should().ThrowAsync<ArgumentNullException>();

act = () => client.Episodes.GetEpisodeStatisticsAsync(new TraktShowIds(), SEASON_NR, EPISODE_NR);
await act.Should().ThrowAsync<ArgumentException>();

act = () => client.Episodes.GetEpisodeStatisticsAsync(0, SEASON_NR, EPISODE_NR);
await act.Should().ThrowAsync<ArgumentException>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ public async Task Test_TraktEpisodesModule_GetEpisodeTranslations_Throws_Argumen
Func<Task<TraktListResponse<ITraktEpisodeTranslation>>> act = () => client.Episodes.GetEpisodeTranslationsAsync(default(ITraktShowIds), SEASON_NR, EPISODE_NR);
await act.Should().ThrowAsync<ArgumentNullException>();

act = () => client.Episodes.GetEpisodeTranslationsAsync(new TraktShowIds(), SEASON_NR, EPISODE_NR);
await act.Should().ThrowAsync<ArgumentException>();

act = () => client.Episodes.GetEpisodeTranslationsAsync(0, SEASON_NR, EPISODE_NR);
await act.Should().ThrowAsync<ArgumentException>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ public async Task Test_TraktEpisodesModule_GetEpisodeWatchingUsers_Throws_Argume
Func<Task<TraktListResponse<ITraktUser>>> act = () => client.Episodes.GetEpisodeWatchingUsersAsync(default(ITraktShowIds), SEASON_NR, EPISODE_NR);
await act.Should().ThrowAsync<ArgumentNullException>();

act = () => client.Episodes.GetEpisodeWatchingUsersAsync(new TraktShowIds(), SEASON_NR, EPISODE_NR);
await act.Should().ThrowAsync<ArgumentException>();

act = () => client.Episodes.GetEpisodeWatchingUsersAsync(0, SEASON_NR, EPISODE_NR);
await act.Should().ThrowAsync<ArgumentException>();
}
Expand Down
Loading

0 comments on commit e8cc6a0

Please sign in to comment.