// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers() .AddNewtonsoftJson(o => o.SerializerSettings.ContractResolver = new DefaultContractResolver() { NamingStrategy = new SnakeCaseNamingStrategy() }); services.AddResponseCaching(); services.AddResponseCompression(options => { options.EnableForHttps = true; }); // register the client as a singleton services.AddSingleton <IElasticClient>(ForecastSearchConfiguration.GetClient()); services.AddSingleton <IConnectionMultiplexer>(ConnectionMultiplexer.Connect("localhost")); services.AddTransient <IForecastSearch, EsForecastSearch>(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Core API", Version = "v1" }); // Set the comments path for the Swagger JSON and UI. var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); c.IncludeXmlComments(xmlPath); }); services.AddSwaggerGenNewtonsoftSupport(); }
public void Setup() { _client = ForecastSearchConfiguration.GetClient(); _logger = new Mock <ILogger <EsForecastSearch> >(); _redis = ConnectionMultiplexer.Connect("localhost"); _forecastSearch = new EsForecastSearch( client: _client, logger: _logger.Object, redis: _redis ); }