Fix unit tests breaking due to config changes

This commit is contained in:
jvyden 2021-11-19 00:42:46 -05:00
parent 177befde91
commit cbe8fbc2b4
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
3 changed files with 6 additions and 0 deletions

View file

@ -8,6 +8,7 @@ namespace LBPUnion.ProjectLighthouse.Tests
{
public DatabaseFact()
{
ServerSettings.Instance = new ServerSettings();
ServerSettings.Instance.DbConnectionString = "server=127.0.0.1;uid=root;pwd=lighthouse;database=lighthouse";
if (!ServerStatics.DbConnected)
{

View file

@ -13,6 +13,8 @@ namespace LBPUnion.ProjectLighthouse.Types.Settings
{
static ServerSettings()
{
if (ServerStatics.IsUnitTesting) return; // Unit testing, we don't want to read configurations here since the tests will provide their own
if (File.Exists(ConfigFileName))
{
string configFile = File.ReadAllText(ConfigFileName);

View file

@ -1,5 +1,6 @@
#nullable enable
using System;
using System.Linq;
using Kettu;
using LBPUnion.ProjectLighthouse.Logging;
@ -29,5 +30,7 @@ namespace LBPUnion.ProjectLighthouse.Types.Settings
}
}
}
public static bool IsUnitTesting => AppDomain.CurrentDomain.GetAssemblies().Any(assembly => assembly.FullName.StartsWith("xunit"));
}
}