-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathIntegrationTestBase.cs
More file actions
40 lines (32 loc) · 1.02 KB
/
IntegrationTestBase.cs
File metadata and controls
40 lines (32 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace MaIN.Core.E2ETests;
public class IntegrationTestBase : IDisposable
{
protected readonly IHost _host;
protected readonly IServiceProvider _services;
protected IntegrationTestBase()
{
_host = Host.CreateDefaultBuilder()
.ConfigureServices((context, services) =>
{
services.AddMaIN(context.Configuration);
ConfigureServices(services);
})
.Build();
_host.Services.UseMaIN();
_host.Start();
_services = _host.Services;
}
// Allow derived classes to add additional services or override existing ones
protected virtual void ConfigureServices(IServiceCollection services)
{
}
protected T GetService<T>() where T : notnull => _services.GetRequiredService<T>();
public void Dispose()
{
_host.Dispose();
GC.SuppressFinalize(this);
}
}