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;
|
2021-05-30 18:16:01 +00:00
|
|
|
|
using MongoDB.Driver;
|
2021-06-21 14:46:44 +00:00
|
|
|
|
using Retroactiune.Core.Interfaces;
|
|
|
|
|
using Retroactiune.Core.Services;
|
|
|
|
|
using Retroactiune.Infrastructure;
|
2021-05-30 15:29:30 +00:00
|
|
|
|
|
|
|
|
|
namespace Retroactiune
|
|
|
|
|
{
|
|
|
|
|
public class TestingStartup
|
|
|
|
|
{
|
2021-06-15 20:08:15 +00:00
|
|
|
|
public TestingStartup()
|
2021-05-30 15:29:30 +00:00
|
|
|
|
{
|
|
|
|
|
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
|
2021-06-11 20:17:03 +00:00
|
|
|
|
services.Configure<DatabaseSettings>(Configuration.GetSection(nameof(DatabaseSettings)));
|
|
|
|
|
services.AddSingleton<IDatabaseSettings>(sp =>
|
|
|
|
|
sp.GetRequiredService<IOptions<DatabaseSettings>>().Value);
|
2021-05-30 15:29:30 +00:00
|
|
|
|
|
|
|
|
|
services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
|
|
|
|
|
|
|
|
|
|
// Services
|
2021-07-04 14:39:07 +00:00
|
|
|
|
services.AddSingleton<IFeedbackReceiversService, FeedbackReceiversService>();
|
2021-07-04 11:05:53 +00:00
|
|
|
|
services.AddSingleton<ITokensService, TokensService>();
|
2021-07-04 17:34:10 +00:00
|
|
|
|
services.AddSingleton<IFeedbacksService, FeedbacksService>();
|
2021-05-30 18:16:01 +00:00
|
|
|
|
services.AddSingleton<IMongoClient, MongoClient>(i =>
|
|
|
|
|
{
|
2021-06-11 20:17:03 +00:00
|
|
|
|
var settings = i.GetService<IOptions<DatabaseSettings>>();
|
2021-05-30 18:16:01 +00:00
|
|
|
|
return new MongoClient(settings.Value.ConnectionString);
|
|
|
|
|
});
|
|
|
|
|
|
2021-05-30 15:29:30 +00:00
|
|
|
|
// 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(); });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|