mirror of
https://github.com/bitwarden/server.git
synced 2024-12-01 13:43:23 +01:00
27 lines
1.1 KiB
C#
27 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using Bit.Infrastructure.EntityFramework.Repositories;
|
|
using Bit.Test.Common.Helpers.Factories;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Bit.Core.Test.Helpers.Factories
|
|
{
|
|
public static class DatabaseOptionsFactory
|
|
{
|
|
public static List<DbContextOptions<DatabaseContext>> Options { get; } = new();
|
|
|
|
static DatabaseOptionsFactory()
|
|
{
|
|
var globalSettings = GlobalSettingsFactory.GlobalSettings;
|
|
if (!string.IsNullOrWhiteSpace(GlobalSettingsFactory.GlobalSettings.PostgreSql?.ConnectionString))
|
|
{
|
|
Options.Add(new DbContextOptionsBuilder<DatabaseContext>().UseNpgsql(globalSettings.PostgreSql.ConnectionString).Options);
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(GlobalSettingsFactory.GlobalSettings.MySql?.ConnectionString))
|
|
{
|
|
var mySqlConnectionString = globalSettings.MySql.ConnectionString;
|
|
Options.Add(new DbContextOptionsBuilder<DatabaseContext>().UseMySql(mySqlConnectionString, ServerVersion.AutoDetect(mySqlConnectionString)).Options);
|
|
}
|
|
}
|
|
}
|
|
}
|