public MovieDatabaseApiClientConfigurationTests()
        {
            var fixture = new Fixture();

            _validator = new MovieDatabaseApiClientConfigurationValidator();

            _configuration = fixture.Create <MovieDatabaseApiClientConfiguration>();
        }
Exemple #2
0
        public static IServiceCollection AddMovieDatabaseProvider(this IServiceCollection services, IConfiguration configuration)
        {
            var movieDatabaseSettings          = configuration.GetSection("MovieDatabaseSettings").Get <MovieDatabaseApiClientConfiguration>();
            var movieDatabaseSettingsValidator = new MovieDatabaseApiClientConfigurationValidator();

            movieDatabaseSettingsValidator.ValidateAndThrow(movieDatabaseSettings);

            services.AddSingleton <IMovieDatabaseApiClientConfiguration>(movieDatabaseSettings);

            var restClientOptions = new RestClientOptions(movieDatabaseSettings.BaseUrl);
            var restClient        = new RestClient(restClientOptions);

            restClient.UseNewtonsoftJson();

            services.AddScoped <IMovieDatabaseApiClient, MovieDatabaseApiClient>(_ => new MovieDatabaseApiClient(movieDatabaseSettings, restClient));
            services.AddScoped <IMovieDatabaseProvider, MovieDatabaseProvider>();

            return(services);
        }