forked from dotnet/efcore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ServiceProviderFixtureBase.cs
26 lines (22 loc) · 1009 Bytes
/
ServiceProviderFixtureBase.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
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.EntityFrameworkCore
{
public abstract class ServiceProviderFixtureBase : FixtureBase
{
public IServiceProvider ServiceProvider { get; }
protected abstract ITestStoreFactory TestStoreFactory { get; }
protected ServiceProviderFixtureBase()
{
ServiceProvider = AddServices(TestStoreFactory.AddProviderServices(new ServiceCollection()))
.BuildServiceProvider(validateScopes: true);
}
public DbContextOptions CreateOptions(TestStore testStore)
=> AddOptions(testStore.AddProviderOptions(new DbContextOptionsBuilder()))
.UseInternalServiceProvider(ServiceProvider)
.Options;
}
}