Skip to content

Commit 1bf4e36

Browse files
authored
Replace hardcoded config file names with constants in unit tests to fix teardown issue (#5252)
1 parent f901cdd commit 1bf4e36

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/ServiceControl.Audit.UnitTests/PopulateAppSettingsTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ namespace ServiceControl.UnitTests;
1010
[TestFixture]
1111
public class PopulateAppSettingsTests
1212
{
13+
const string ConfigFileName = "ServiceControl.Audit.exe.config";
14+
1315
[Test]
1416
public async Task Should_populate_appSettings_from_exe_config_file()
1517
{
@@ -24,7 +26,7 @@ public async Task Should_populate_appSettings_from_exe_config_file()
2426
</configuration>
2527
""";
2628

27-
await File.WriteAllTextAsync("ServiceControl.Audit.exe.config", config);
29+
await File.WriteAllTextAsync(ConfigFileName, config);
2830

2931
var fileName = "ServiceControl.Audit";
3032
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
@@ -70,5 +72,5 @@ public async Task Should_populate_appSettings_from_exe_config_file()
7072
}
7173

7274
[TearDown]
73-
public void TearDown() => File.Delete("ServiceControl.exe.config");
75+
public void TearDown() => File.Delete(ConfigFileName);
7476
}

src/ServiceControl.Monitoring.UnitTests/PopulateAppSettingsTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ namespace ServiceControl.UnitTests;
1010
[TestFixture]
1111
public class PopulateAppSettingsTests
1212
{
13+
const string ConfigFileName = "ServiceControl.Monitoring.exe.config";
14+
1315
[Test]
1416
public async Task Should_populate_appSettings_from_exe_config_file()
1517
{
@@ -24,7 +26,7 @@ public async Task Should_populate_appSettings_from_exe_config_file()
2426
</configuration>
2527
""";
2628

27-
await File.WriteAllTextAsync("ServiceControl.Monitoring.exe.config", config);
29+
await File.WriteAllTextAsync(ConfigFileName, config);
2830

2931
var fileName = "ServiceControl.Monitoring";
3032
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
@@ -74,5 +76,5 @@ public async Task Should_populate_appSettings_from_exe_config_file()
7476
}
7577

7678
[TearDown]
77-
public void TearDown() => File.Delete("ServiceControl.exe.config");
79+
public void TearDown() => File.Delete(ConfigFileName);
7880
}

src/ServiceControl.UnitTests/PopulateAppSettingsTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ namespace ServiceControl.UnitTests;
1010
[TestFixture]
1111
public class PopulateAppSettingsTests
1212
{
13+
const string ConfigFileName = "ServiceControl.exe.config";
14+
1315
[Test]
1416
public async Task Should_populate_appSettings_from_exe_config_file()
1517
{
@@ -24,7 +26,7 @@ public async Task Should_populate_appSettings_from_exe_config_file()
2426
</configuration>
2527
""";
2628

27-
await File.WriteAllTextAsync("ServiceControl.exe.config", config);
29+
await File.WriteAllTextAsync(ConfigFileName, config);
2830

2931
var fileName = "ServiceControl";
3032
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
@@ -72,5 +74,5 @@ public async Task Should_populate_appSettings_from_exe_config_file()
7274
}
7375

7476
[TearDown]
75-
public void TearDown() => File.Delete("ServiceControl.exe.config");
77+
public void TearDown() => File.Delete(ConfigFileName);
7678
}

0 commit comments

Comments
 (0)