From 3f64735e3c9ee87ad0d91e9a825f324b379d750f Mon Sep 17 00:00:00 2001 From: Bob Langley Date: Fri, 8 Mar 2019 14:49:51 -0800 Subject: [PATCH] Add api approvals for settings file --- .../API/SettingsTests.cs | 15 +++++++++++++++ src/ServiceControl.Monitoring.Tests/App.config | 9 +++++++++ ...ngsTests.PlatformSampleSettings.approved.txt | 17 +++++++++++++++++ .../ServiceControl.Monitoring.Tests.csproj | 2 +- src/ServiceControl.Monitoring/Settings.cs | 2 +- 5 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 src/ServiceControl.Monitoring.Tests/API/SettingsTests.cs create mode 100644 src/ServiceControl.Monitoring.Tests/App.config create mode 100644 src/ServiceControl.Monitoring.Tests/ApprovalFiles/SettingsTests.PlatformSampleSettings.approved.txt diff --git a/src/ServiceControl.Monitoring.Tests/API/SettingsTests.cs b/src/ServiceControl.Monitoring.Tests/API/SettingsTests.cs new file mode 100644 index 0000000..ca2f065 --- /dev/null +++ b/src/ServiceControl.Monitoring.Tests/API/SettingsTests.cs @@ -0,0 +1,15 @@ +namespace ServiceControl.Monitoring.Tests.API +{ + using System.Configuration; + using NUnit.Framework; + using Particular.Approvals; + + class SettingsTests + { + [Test] + public void PlatformSampleSettings() + { + Approver.Verify(Settings.Load(new SettingsReader(ConfigurationManager.AppSettings))); + } + } +} diff --git a/src/ServiceControl.Monitoring.Tests/App.config b/src/ServiceControl.Monitoring.Tests/App.config new file mode 100644 index 0000000..ed4fa22 --- /dev/null +++ b/src/ServiceControl.Monitoring.Tests/App.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/ServiceControl.Monitoring.Tests/ApprovalFiles/SettingsTests.PlatformSampleSettings.approved.txt b/src/ServiceControl.Monitoring.Tests/ApprovalFiles/SettingsTests.PlatformSampleSettings.approved.txt new file mode 100644 index 0000000..5a184c5 --- /dev/null +++ b/src/ServiceControl.Monitoring.Tests/ApprovalFiles/SettingsTests.PlatformSampleSettings.approved.txt @@ -0,0 +1,17 @@ +{ + "EndpointName": "Particular.Monitoring", + "ServiceName": "Particular.Monitoring", + "TransportType": "NServiceBus.ServiceControlLearningTransport, ServiceControl.Transports.LearningTransport", + "ErrorQueue": "error", + "LogPath": "C:\\Logs", + "LogLevel": { + "Name": "Warn", + "Ordinal": 3 + }, + "Username": null, + "EnableInstallers": false, + "HttpHostName": "localhost", + "HttpPort": "9999", + "EndpointUptimeGracePeriod": "00:00:40", + "SkipQueueCreation": false +} \ No newline at end of file diff --git a/src/ServiceControl.Monitoring.Tests/ServiceControl.Monitoring.Tests.csproj b/src/ServiceControl.Monitoring.Tests/ServiceControl.Monitoring.Tests.csproj index 6ba8f60..2c0f904 100644 --- a/src/ServiceControl.Monitoring.Tests/ServiceControl.Monitoring.Tests.csproj +++ b/src/ServiceControl.Monitoring.Tests/ServiceControl.Monitoring.Tests.csproj @@ -12,7 +12,7 @@ - + \ No newline at end of file diff --git a/src/ServiceControl.Monitoring/Settings.cs b/src/ServiceControl.Monitoring/Settings.cs index 9c74f8a..91007ec 100644 --- a/src/ServiceControl.Monitoring/Settings.cs +++ b/src/ServiceControl.Monitoring/Settings.cs @@ -48,7 +48,7 @@ internal static Settings Load(SettingsReader reader) // debugging or if the entry is removed manually. In those circumstances default to the folder containing the exe internal static string DefaultLogLocation() { - var assemblyLocation = Assembly.GetEntryAssembly().Location; + var assemblyLocation = Assembly.GetExecutingAssembly().Location; return Path.GetDirectoryName(assemblyLocation); } }