Skip to content

Commit d1eb90f

Browse files
committed
Simplify explicit configuration loading check for tests
1 parent a597006 commit d1eb90f

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/NHibernate.Test/TestsContext.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
11
#if NETCOREAPP2_0
2-
32
using NUnit.Framework;
43
using System.Configuration;
5-
using System.IO;
64
using NHibernate.Cfg;
75

86
namespace NHibernate.Test
97
{
108
[SetUpFixture]
119
public class TestsContext
1210
{
13-
private static bool ExecutingWithVsTest { get; } =
14-
System.Reflection.Assembly.GetEntryAssembly()?.GetName().Name == "testhost";
15-
1611
[OneTimeSetUp]
1712
public void RunBeforeAnyTests()
1813
{
1914
//When .NET Core App 2.0 tests run from VS/VSTest the entry assembly is "testhost.dll"
2015
//so we need to explicitly load the configuration
21-
if (ExecutingWithVsTest)
16+
if (System.Reflection.Assembly.GetEntryAssembly() != null)
2217
{
23-
var assemblyPath = Path.Combine(TestContext.CurrentContext.TestDirectory, Path.GetFileName(typeof(TestsContext).Assembly.Location));
24-
ConfigurationProvider.Current = new SystemConfigurationProvider(ConfigurationManager.OpenExeConfiguration(assemblyPath));
18+
ConfigurationProvider.Current = new SystemConfigurationProvider(ConfigurationManager.OpenExeConfiguration(typeof(TestsContext).Assembly.Location));
2519
}
2620
}
2721
}

0 commit comments

Comments
 (0)