-
-
Notifications
You must be signed in to change notification settings - Fork 106
/
Copy pathCustomWebApplicationFactory.cs
30 lines (27 loc) · 1.05 KB
/
CustomWebApplicationFactory.cs
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
// Copyright (c) SimpleIdServer. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.IO;
namespace SimpleIdServer.Scim.Host.Acceptance.Tests
{
public class CustomWebApplicationFactory<T> : WebApplicationFactory<T> where T : class
{
private readonly Action<IServiceCollection> _configureTestServices;
public CustomWebApplicationFactory(Action<IServiceCollection> configureTestServices = null)
{
_configureTestServices = configureTestServices;
}
protected override void ConfigureWebHost(IWebHostBuilder builder)
{
builder.UseContentRoot(Directory.GetCurrentDirectory());
builder.ConfigureServices(collection =>
{
_configureTestServices?.Invoke(collection);
});
}
}
}