diff --git a/src/Elmah.Io.Umbraco/ElmahIoNotificationMethod.cs b/src/Elmah.Io.Umbraco/ElmahIoNotificationMethod.cs
index 77acd9e..065a43c 100644
--- a/src/Elmah.Io.Umbraco/ElmahIoNotificationMethod.cs
+++ b/src/Elmah.Io.Umbraco/ElmahIoNotificationMethod.cs
@@ -16,13 +16,13 @@ namespace Elmah.Io.Umbraco
[HealthCheckNotificationMethod("elmah.io")]
public class ElmahIoNotificationMethod : NotificationMethodBase
{
- internal static string _assemblyVersion = typeof(ElmahIoNotificationMethod).Assembly.GetName().Version.ToString();
- internal static string _umbracoAssemblyVersion = typeof(NotificationMethodBase).Assembly.GetName().Version.ToString();
+ private static string _assemblyVersion = typeof(ElmahIoNotificationMethod).Assembly.GetName().Version.ToString();
+ private static string _umbracoAssemblyVersion = typeof(NotificationMethodBase).Assembly.GetName().Version.ToString();
internal IHeartbeatsClient heartbeats;
- private string apiKey;
- private string logId;
- private string heartbeatId;
+ private readonly string apiKey;
+ private readonly string logId;
+ private readonly string heartbeatId;
///
/// Create a new instance of the notification method. This constructor should not be called manually but invoked
@@ -42,7 +42,6 @@ public ElmahIoNotificationMethod(IOptionsMonitor healthChe
if (string.IsNullOrWhiteSpace(apiKey) || string.IsNullOrWhiteSpace(logId) || string.IsNullOrWhiteSpace(heartbeatId))
{
Enabled = false;
- return;
}
}
@@ -52,7 +51,7 @@ public ElmahIoNotificationMethod(IOptionsMonitor healthChe
///
public override async Task SendAsync(HealthCheckResults results)
{
- if (ShouldSend(results) == false)
+ if (!ShouldSend(results))
{
return;
}
@@ -82,11 +81,11 @@ public override async Task SendAsync(HealthCheckResults results)
});
}
- private string UserAgent()
+ private static string UserAgent()
{
return new StringBuilder()
.Append(new ProductInfoHeaderValue(new ProductHeaderValue("Elmah.Io.Umbraco", _assemblyVersion)).ToString())
- .Append(" ")
+ .Append(' ')
.Append(new ProductInfoHeaderValue(new ProductHeaderValue("Umbraco.Cms", _umbracoAssemblyVersion)).ToString())
.ToString();
}
diff --git a/test/Elmah.Io.Umbraco.Test/ElmahIoNotificationMethodTest.cs b/test/Elmah.Io.Umbraco.Test/ElmahIoNotificationMethodTest.cs
index 1895304..f2bd191 100644
--- a/test/Elmah.Io.Umbraco.Test/ElmahIoNotificationMethodTest.cs
+++ b/test/Elmah.Io.Umbraco.Test/ElmahIoNotificationMethodTest.cs
@@ -18,22 +18,24 @@ public class ElmahIoNotificationMethodTest
public void SetUp()
{
var options = Substitute.For>();
- var settings = new HealthChecksSettings();
- settings.Notification = new HealthChecksNotificationSettings
+ var settings = new HealthChecksSettings
{
- Enabled = true,
- NotificationMethods = new Dictionary
+ Notification = new HealthChecksNotificationSettings
{
+ Enabled = true,
+ NotificationMethods = new Dictionary
{
- "elmah.io", new HealthChecksNotificationMethodSettings
{
- Verbosity = HealthCheckNotificationVerbosity.Summary,
- Enabled = true,
- Settings = new Dictionary
+ "elmah.io", new HealthChecksNotificationMethodSettings
{
- { "apiKey", "API_KEY" },
- { "logId", "LOG_ID" },
- { "heartbeatId", "HEARTBEAT_ID" }
+ Verbosity = HealthCheckNotificationVerbosity.Summary,
+ Enabled = true,
+ Settings = new Dictionary
+ {
+ { "apiKey", "API_KEY" },
+ { "logId", "LOG_ID" },
+ { "heartbeatId", "HEARTBEAT_ID" }
+ }
}
}
}
@@ -41,8 +43,10 @@ public void SetUp()
};
options.CurrentValue.Returns(settings);
heartbeatsClient = Substitute.For();
- sut = new ElmahIoNotificationMethod(options);
- sut.heartbeats = heartbeatsClient;
+ sut = new ElmahIoNotificationMethod(options)
+ {
+ heartbeats = heartbeatsClient
+ };
}
[Test]
@@ -88,7 +92,7 @@ public override Task> GetStatus()
{
return Task.FromResult>(new List
{
- new HealthCheckStatus("Oh no")
+ new("Oh no")
{
ResultType = StatusResultType.Error
}