forked from gitter-badger/IdentityServer4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabaseProviderBuilder.cs
More file actions
43 lines (37 loc) · 1.75 KB
/
Copy pathDatabaseProviderBuilder.cs
File metadata and controls
43 lines (37 loc) · 1.75 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
41
42
43
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
using Microsoft.EntityFrameworkCore;
namespace IdentityServer4.EntityFramework.IntegrationTests
{
/// <summary>
/// Helper methods to initialize DbContextOptions for the specified database provider and context.
/// </summary>
public class DatabaseProviderBuilder
{
public static DbContextOptions<T> BuildInMemory<T>(string name) where T : DbContext
{
var builder = new DbContextOptionsBuilder<T>();
builder.UseInMemoryDatabase(name);
return builder.Options;
}
public static DbContextOptions<T> BuildSqlite<T>(string name) where T : DbContext
{
var builder = new DbContextOptionsBuilder<T>();
builder.UseSqlite($"Filename=./Test.IdentityServer4.EntityFramework-3.1.0.{name}.db");
return builder.Options;
}
public static DbContextOptions<T> BuildLocalDb<T>(string name) where T : DbContext
{
var builder = new DbContextOptionsBuilder<T>();
builder.UseSqlServer(
$@"Data Source=(LocalDb)\MSSQLLocalDB;database=Test.IdentityServer4.EntityFramework-3.1.0.{name};trusted_connection=yes;");
return builder.Options;
}
public static DbContextOptions<T> BuildAppVeyorSqlServer2016<T>(string name) where T : DbContext
{
var builder = new DbContextOptionsBuilder<T>();
builder.UseSqlServer($@"Server=(local)\SQL2016;Database=Test.IdentityServer4.EntityFramework-3.1.0.{name};User ID=sa;Password=Password12!");
return builder.Options;
}
}
}