Skip to content

Commit c60a347

Browse files
committed
Fix location of app.config file in tests
1 parent fcd1287 commit c60a347

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

test/Serilog.Settings.AppSettings.Tests/Settings/AppSettingsTests.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Configuration;
3+
using System.IO;
34
using Xunit;
45
using Serilog.Events;
56
using Serilog.Tests.Support;
@@ -11,8 +12,12 @@ public class AppSettingsTests
1112
{
1213
static AppSettingsTests()
1314
{
14-
AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE",
15-
System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), @"..\..\..\..\app.config"));
15+
var basePath = AppDomain.CurrentDomain.BaseDirectory;
16+
var config = Path.GetFullPath(Path.Combine(basePath, "app.config"));
17+
if (!File.Exists(config))
18+
throw new InvalidOperationException($"Can't find app.config in {basePath}");
19+
20+
AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", config);
1621
}
1722

1823
[Fact]

test/Serilog.Settings.AppSettings.Tests/project.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
},
88
"buildOptions": {
99
"keyFile": "../../assets/Serilog.snk",
10-
"preserveCompilationContext": true
10+
"preserveCompilationContext": true,
11+
"copyToOutput": [ "app.config" ]
1112
},
1213
"frameworks": {
1314
"net4.5.2": {
@@ -16,8 +17,6 @@
1617
},
1718
"dependencies": {
1819
"Newtonsoft.Json": "7.0.1",
19-
"Rx-Main": "2.2.5",
20-
"xunit.runner.visualstudio": "2.1.0",
2120
"Serilog.Sinks.TextWriter": "2.0.0",
2221
"Serilog.Sinks.RollingFile": "2.0.0",
2322
"Serilog.Sinks.PeriodicBatching": "2.0.0",

0 commit comments

Comments
 (0)