ProjectLighthouse/ProjectLighthouse.Tests/DatabaseFactAttribute.cs
Josh 20b2ef5700
Rework CI and add game server login tests (#615)
* Make tests run in release mode

* Fix multiple command in ci

* I forgot how yaml works

* Shitty workaround

* grr mondays

* Add an NP ticket builder for unit tests

* Add NP ticket unit testing

* Fix range indexers for finding uid

* Fix LoginTests

* Validate unit test signatures

* Make builder code follow same style conventions

* Remove remnant of hardcoded issuer id
2023-01-07 00:12:39 -06:00

25 lines
No EOL
733 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 = new ServerConfiguration
{
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();
}
}
}