ProjectLighthouse/ProjectLighthouse.Tests/DatabaseFactAttribute.cs
Josh c86d2a11b5
Abstract config design and update logging format (#624)
* Abstract config design and update logging pattern
Also drops legacy config support

* Fix unit tests

* Make backup of config file when upgrading

* Use shared process semaphore to fix migration race conditions

* Use mutex because semaphore isn't supported

* Make startup wait for configs to load

* Move mutex to config load instead of constructor

* Add debug logging

* Make mutex static

* Change mutex name format

* Make mutex use global namespace

* Remove debug logging and fix config upgrading

* Rename lambda variable
2023-01-10 17:29:47 -06:00

22 lines
No EOL
675 B
C#

using LBPUnion.ProjectLighthouse.Configuration;
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 Database database = new();
database.Database.Migrate();
}
}
}