public void TestTraktPeopleModuleGetPersonShowCreditsExceptions() { var personId = "297737"; var uri = $"people/{personId}/shows"; TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.NotFound); Func <Task <TraktPersonShowCredits> > act = async() => await TestUtility.MOCK_TEST_CLIENT.People.GetPersonShowCreditsAsync(personId); act.ShouldThrow <TraktPersonNotFoundException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.Unauthorized); act.ShouldThrow <TraktAuthorizationException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.BadRequest); act.ShouldThrow <TraktBadRequestException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.Forbidden); act.ShouldThrow <TraktForbiddenException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.MethodNotAllowed); act.ShouldThrow <TraktMethodNotFoundException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.Conflict); act.ShouldThrow <TraktConflictException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.InternalServerError); act.ShouldThrow <TraktServerException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.BadGateway); act.ShouldThrow <TraktBadGatewayException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, (HttpStatusCode)412); act.ShouldThrow <TraktPreconditionFailedException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, (HttpStatusCode)422); act.ShouldThrow <TraktValidationException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, (HttpStatusCode)429); act.ShouldThrow <TraktRateLimitException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, (HttpStatusCode)503); act.ShouldThrow <TraktServerUnavailableException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, (HttpStatusCode)504); act.ShouldThrow <TraktServerUnavailableException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, (HttpStatusCode)520); act.ShouldThrow <TraktServerUnavailableException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, (HttpStatusCode)521); act.ShouldThrow <TraktServerUnavailableException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, (HttpStatusCode)522); act.ShouldThrow <TraktServerUnavailableException>(); }
public void CleanupSingleTest() { TestUtility.ClearMockHttpClient(); }
public void TestTraktEpisodesModuleGetEpisodeWatchingUsersExceptions() { var showId = "1390"; var seasonNr = 1; var episodeNr = 1; var uri = $"shows/{showId}/seasons/{seasonNr}/episodes/{episodeNr}/watching"; TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.NotFound); Func <Task <IEnumerable <TraktUser> > > act = async() => await TestUtility.MOCK_TEST_CLIENT.Episodes.GetEpisodeWatchingUsersAsync(showId, seasonNr, episodeNr); act.ShouldThrow <TraktEpisodeNotFoundException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.Unauthorized); act.ShouldThrow <TraktAuthorizationException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.BadRequest); act.ShouldThrow <TraktBadRequestException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.Forbidden); act.ShouldThrow <TraktForbiddenException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.MethodNotAllowed); act.ShouldThrow <TraktMethodNotFoundException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.Conflict); act.ShouldThrow <TraktConflictException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.InternalServerError); act.ShouldThrow <TraktServerException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.BadGateway); act.ShouldThrow <TraktBadGatewayException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, (HttpStatusCode)412); act.ShouldThrow <TraktPreconditionFailedException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, (HttpStatusCode)422); act.ShouldThrow <TraktValidationException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, (HttpStatusCode)429); act.ShouldThrow <TraktRateLimitException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, (HttpStatusCode)503); act.ShouldThrow <TraktServerUnavailableException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, (HttpStatusCode)504); act.ShouldThrow <TraktServerUnavailableException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, (HttpStatusCode)520); act.ShouldThrow <TraktServerUnavailableException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, (HttpStatusCode)521); act.ShouldThrow <TraktServerUnavailableException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, (HttpStatusCode)522); act.ShouldThrow <TraktServerUnavailableException>(); }
public void TestTraktGenresModuleGetMovieGenresExceptions() { var uri = "genres/movies"; TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.NotFound); Func <Task <IEnumerable <TraktGenre> > > act = async() => await TestUtility.MOCK_TEST_CLIENT.Genres.GetMovieGenresAsync(); act.ShouldThrow <TraktNotFoundException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.Unauthorized); act.ShouldThrow <TraktAuthorizationException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.BadRequest); act.ShouldThrow <TraktBadRequestException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.Forbidden); act.ShouldThrow <TraktForbiddenException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.MethodNotAllowed); act.ShouldThrow <TraktMethodNotFoundException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.Conflict); act.ShouldThrow <TraktConflictException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.InternalServerError); act.ShouldThrow <TraktServerException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.BadGateway); act.ShouldThrow <TraktBadGatewayException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, (HttpStatusCode)412); act.ShouldThrow <TraktPreconditionFailedException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, (HttpStatusCode)422); act.ShouldThrow <TraktValidationException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, (HttpStatusCode)429); act.ShouldThrow <TraktRateLimitException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, (HttpStatusCode)503); act.ShouldThrow <TraktServerUnavailableException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, (HttpStatusCode)504); act.ShouldThrow <TraktServerUnavailableException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, (HttpStatusCode)520); act.ShouldThrow <TraktServerUnavailableException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, (HttpStatusCode)521); act.ShouldThrow <TraktServerUnavailableException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithoutOAuth(uri, (HttpStatusCode)522); act.ShouldThrow <TraktServerUnavailableException>(); }
public void TestTraktRecommendationsModuleHideUserShowRecommendationExceptions() { var showId = "1390"; var uri = $"recommendations/shows/{showId}"; TestUtility.SetupMockResponseWithoutOAuth(uri, HttpStatusCode.Unauthorized); Func <Task> act = async() => await TestUtility.MOCK_TEST_CLIENT.Recommendations.HideShowRecommendationAsync(showId); act.ShouldThrow <TraktAuthorizationException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithOAuth(uri, HttpStatusCode.NotFound); act.ShouldThrow <TraktShowNotFoundException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithOAuth(uri, HttpStatusCode.BadRequest); act.ShouldThrow <TraktBadRequestException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithOAuth(uri, HttpStatusCode.Forbidden); act.ShouldThrow <TraktForbiddenException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithOAuth(uri, HttpStatusCode.MethodNotAllowed); act.ShouldThrow <TraktMethodNotFoundException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithOAuth(uri, HttpStatusCode.Conflict); act.ShouldThrow <TraktConflictException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithOAuth(uri, HttpStatusCode.InternalServerError); act.ShouldThrow <TraktServerException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithOAuth(uri, HttpStatusCode.BadGateway); act.ShouldThrow <TraktBadGatewayException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithOAuth(uri, (HttpStatusCode)412); act.ShouldThrow <TraktPreconditionFailedException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithOAuth(uri, (HttpStatusCode)422); act.ShouldThrow <TraktValidationException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithOAuth(uri, (HttpStatusCode)429); act.ShouldThrow <TraktRateLimitException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithOAuth(uri, (HttpStatusCode)503); act.ShouldThrow <TraktServerUnavailableException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithOAuth(uri, (HttpStatusCode)504); act.ShouldThrow <TraktServerUnavailableException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithOAuth(uri, (HttpStatusCode)520); act.ShouldThrow <TraktServerUnavailableException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithOAuth(uri, (HttpStatusCode)521); act.ShouldThrow <TraktServerUnavailableException>(); TestUtility.ClearMockHttpClient(); TestUtility.SetupMockResponseWithOAuth(uri, (HttpStatusCode)522); act.ShouldThrow <TraktServerUnavailableException>(); }