forked from stuartcarnie/nhibernate-test
-
Notifications
You must be signed in to change notification settings - Fork 19
/
TestsContext.cs
35 lines (31 loc) · 1.03 KB
/
TestsContext.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using NUnit.Framework;
using System.Configuration;
using System.Reflection;
using log4net;
using log4net.Config;
using NHibernate.Cfg;
namespace NHibernate.Test
{
[SetUpFixture]
public class TestsContext
{
private static readonly Assembly TestAssembly = typeof(TestsContext).Assembly;
[OneTimeSetUp]
public void RunBeforeAnyTests()
{
ConfigureLog4Net();
//When .NET Core App 2.0 tests run from VS/VSTest the entry assembly is "testhost.dll"
//so we need to explicitly load the configuration
if (Assembly.GetEntryAssembly() != null)
{
//NOTE Can be safely commented if App.config is not used by test
ConfigurationProvider.Current = new SystemConfigurationProvider(ConfigurationManager.OpenExeConfiguration(TestAssembly.Location));
}
}
private static void ConfigureLog4Net()
{
using (var log4NetXml = TestAssembly.GetManifestResourceStream("NHibernate.Test.log4net.xml"))
XmlConfigurator.Configure(LogManager.GetRepository(TestAssembly), log4NetXml);
}
}
}