mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-12 21:02:27 +00:00
Refactor Database into DatabaseContext Moved into separate folder so it actually has a namespace instead sitting in the root
23 lines
No EOL
725 B
C#
23 lines
No EOL
725 B
C#
using LBPUnion.ProjectLighthouse.Configuration;
|
|
using LBPUnion.ProjectLighthouse.Database;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Xunit;
|
|
|
|
namespace LBPUnion.ProjectLighthouse.Tests;
|
|
|
|
public sealed class DatabaseFactAttribute : FactAttribute
|
|
{
|
|
private static readonly object migrateLock = new();
|
|
|
|
public DatabaseFactAttribute()
|
|
{
|
|
ServerConfiguration.Instance.DbConnectionString = "server=127.0.0.1;uid=root;pwd=lighthouse;database=lighthouse";
|
|
if (!ServerStatics.DbConnected) this.Skip = "Database not available";
|
|
else
|
|
lock (migrateLock)
|
|
{
|
|
using DatabaseContext database = new();
|
|
database.Database.Migrate();
|
|
}
|
|
}
|
|
} |