forked from nhibernate/nhibernate-core-testcase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestConfigurationHelper.cs
38 lines (34 loc) · 1.15 KB
/
TestConfigurationHelper.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
36
37
38
namespace NHibernate.Test
{
using System;
using System.IO;
using Cfg;
public static class TestConfigurationHelper
{
public static readonly string hibernateConfigFile;
static TestConfigurationHelper()
{
// Verify if hibernate.cfg.xml exists
hibernateConfigFile = TestConfigurationHelper.GetDefaultConfigurationFilePath();
}
public static string GetDefaultConfigurationFilePath()
{
string baseDir = AppDomain.CurrentDomain.BaseDirectory;
string relativeSearchPath = AppDomain.CurrentDomain.RelativeSearchPath;
string binPath = relativeSearchPath == null ? baseDir : Path.Combine(baseDir, relativeSearchPath);
string fullPath = Path.Combine(binPath, Cfg.Configuration.DefaultHibernateCfgFileName);
return File.Exists(fullPath) ? fullPath : null;
}
/// <summary>
/// Standar Configuration for tests.
/// </summary>
/// <returns>The configuration using merge between App.Config and hibernate.cfg.xml if present.</returns>
public static Configuration GetDefaultConfiguration()
{
Configuration result = new Configuration();
if (hibernateConfigFile != null)
result.Configure(hibernateConfigFile);
return result;
}
}
}