Skip to content

Commit e531577

Browse files
committed
Update config files for test projects
1 parent 05401e8 commit e531577

File tree

8 files changed

+45
-58
lines changed

8 files changed

+45
-58
lines changed

Tests.NHibernate.Spatial.MsSql2008/TestConfiguration.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Microsoft.Extensions.Configuration;
12
using NHibernate.Bytecode;
23
using NHibernate.Cfg;
34
using NHibernate.Driver;
@@ -8,6 +9,15 @@ namespace Tests.NHibernate.Spatial
89
{
910
internal static class TestConfiguration
1011
{
12+
private static readonly IConfigurationRoot _configurationRoot;
13+
14+
static TestConfiguration()
15+
{
16+
_configurationRoot = new ConfigurationBuilder()
17+
.AddJsonFile("appsettings.json")
18+
.Build();
19+
}
20+
1121
public static void Configure(Configuration configuration)
1222
{
1323
IDictionary<string, string> properties = new Dictionary<string, string>
@@ -16,7 +26,7 @@ public static void Configure(Configuration configuration)
1626
[Environment.Dialect] = typeof(MsSql2008GeometryDialect).AssemblyQualifiedName,
1727
[Environment.ConnectionProvider] = typeof(DebugConnectionProvider).AssemblyQualifiedName,
1828
[Environment.ConnectionDriver] = typeof(SqlClientDriver).AssemblyQualifiedName,
19-
[Environment.ConnectionString] = System.Configuration.ConfigurationManager.ConnectionStrings["SqlServer2008"].ConnectionString
29+
[Environment.ConnectionString] = _configurationRoot.GetConnectionString("MsSql2008")
2030
};
2131
configuration.SetProperties(properties);
2232
}

Tests.NHibernate.Spatial.MsSql2008/Tests.NHibernate.Spatial.MsSql2008.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,10 @@
1919
<ProjectReference Include="..\Tests.NHibernate.Spatial\Tests.NHibernate.Spatial.csproj" />
2020
</ItemGroup>
2121

22+
<ItemGroup>
23+
<None Update="appsettings.json">
24+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
25+
</None>
26+
</ItemGroup>
27+
2228
</Project>

Tests.NHibernate.Spatial.MsSql2008/app.config

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"ConnectionStrings": {
3+
"_comment": " NOTE: Must specify SQL Server 2012 rather than SQL Server 2008 for the Type System Version attribute (see issue #72)",
4+
"MsSql2008": "Server=(local)\\SQL2008R2SP2;Initial Catalog=nhsp_test;User ID=nhsp_test;Password=nhsp_test;Type System Version=SQL Server 2012"
5+
}
6+
}

Tests.NHibernate.Spatial.MsSql2012/TestConfiguration.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Microsoft.Extensions.Configuration;
12
using NHibernate.Bytecode;
23
using NHibernate.Cfg;
34
using NHibernate.Driver;
@@ -8,6 +9,15 @@ namespace Tests.NHibernate.Spatial
89
{
910
internal static class TestConfiguration
1011
{
12+
private static readonly IConfigurationRoot _configurationRoot;
13+
14+
static TestConfiguration()
15+
{
16+
_configurationRoot = new ConfigurationBuilder()
17+
.AddJsonFile("appsettings.json")
18+
.Build();
19+
}
20+
1121
public static void Configure(Configuration configuration)
1222
{
1323
IDictionary<string, string> properties = new Dictionary<string, string>
@@ -16,7 +26,7 @@ public static void Configure(Configuration configuration)
1626
[Environment.Dialect] = typeof(MsSql2012GeometryDialect).AssemblyQualifiedName,
1727
[Environment.ConnectionProvider] = typeof(DebugConnectionProvider).AssemblyQualifiedName,
1828
[Environment.ConnectionDriver] = typeof(SqlClientDriver).AssemblyQualifiedName,
19-
[Environment.ConnectionString] = System.Configuration.ConfigurationManager.ConnectionStrings["SqlServer2012"].ConnectionString
29+
[Environment.ConnectionString] = _configurationRoot.GetConnectionString("MsSql2012")
2030
};
2131
configuration.SetProperties(properties);
2232
}

Tests.NHibernate.Spatial.MsSql2012/Tests.NHibernate.Spatial.MsSql2012.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,10 @@
1818
<ProjectReference Include="..\Tests.NHibernate.Spatial.MsSql2008\Tests.NHibernate.Spatial.MsSql2008.csproj" />
1919
</ItemGroup>
2020

21+
<ItemGroup>
22+
<None Update="appsettings.json">
23+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
24+
</None>
25+
</ItemGroup>
26+
2127
</Project>

Tests.NHibernate.Spatial.MsSql2012/app.config

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"ConnectionStrings": {
3+
"MsSql2012": "Server=(local)\\SQL2012SP1;Initial Catalog=nhsp_test;User ID=nhsp_test;Password=nhsp_test;Type System Version=SQL Server 2012"
4+
}
5+
}

0 commit comments

Comments
 (0)