retroactiune/Retroactiune.WebAPI/TestingStartup.cs

50 lines
1.7 KiB
C#
Raw Normal View History

2021-05-30 15:29:30 +00:00
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Retroactiune.Services;
using Retroactiune.Settings;
namespace Retroactiune
{
public class TestingStartup
{
public TestingStartup(IConfiguration configuration)
{
var configurationBuilder = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.Testing.json");
Configuration = configurationBuilder.Build();
}
private IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Database Configuration
services.Configure<RetroactiuneDbSettings>(Configuration.GetSection(nameof(RetroactiuneDbSettings)));
services.AddSingleton<IMongoDbSettings>(sp =>
sp.GetRequiredService<IOptions<RetroactiuneDbSettings>>().Value);
services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
// Services
services.AddSingleton<IFeedbackReceiverService, FeedbackReceiverService>();
// WebAPI
services.AddControllers();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app)
{
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
}
}
}