diff --git a/src/Exceptionless/Logging/FileExceptionlessLog.cs b/src/Exceptionless/Logging/FileExceptionlessLog.cs index 540c9817..7d395b07 100644 --- a/src/Exceptionless/Logging/FileExceptionlessLog.cs +++ b/src/Exceptionless/Logging/FileExceptionlessLog.cs @@ -23,13 +23,13 @@ public FileExceptionlessLog(string filePath, bool append = false) { MinimumLogLevel = LogLevel.Trace; _append = append; - Init(); + Initialize(); // flush the log every 3 seconds instead of on every write _flushTimer = new Timer(OnFlushTimer, null, TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(3)); } - protected virtual void Init() { + protected virtual void Initialize() { if (!Path.IsPathRooted(FilePath)) FilePath = Path.GetFullPath(FilePath); diff --git a/src/Exceptionless/Logging/IsolatedStorageFileExceptionlessLog.cs b/src/Exceptionless/Logging/IsolatedStorageFileExceptionlessLog.cs index 6440f038..ca009220 100644 --- a/src/Exceptionless/Logging/IsolatedStorageFileExceptionlessLog.cs +++ b/src/Exceptionless/Logging/IsolatedStorageFileExceptionlessLog.cs @@ -9,7 +9,7 @@ namespace Exceptionless.Logging { public class IsolatedStorageFileExceptionlessLog : FileExceptionlessLog { public IsolatedStorageFileExceptionlessLog(string filePath, bool append = false) : base(filePath, append) {} - protected override void Init() {} + protected override void Initialize() {} private IsolatedStorageFile GetStore() { #if NETSTANDARD diff --git a/src/Platforms/Exceptionless.NLog/ExceptionlessTarget.cs b/src/Platforms/Exceptionless.NLog/ExceptionlessTarget.cs index 2cc39981..83c7128c 100644 --- a/src/Platforms/Exceptionless.NLog/ExceptionlessTarget.cs +++ b/src/Platforms/Exceptionless.NLog/ExceptionlessTarget.cs @@ -9,7 +9,7 @@ namespace Exceptionless.NLog { [Target("Exceptionless")] - public class ExceptionlessTarget : TargetWithLayout { + public sealed class ExceptionlessTarget : TargetWithLayout { private ExceptionlessClient _client = ExceptionlessClient.Default; public Layout ApiKey { get; set; } diff --git a/test/Exceptionless.MessagePack.Tests/MessagePackStorageSerializerTests.cs b/test/Exceptionless.MessagePack.Tests/MessagePackStorageSerializerTests.cs index 6c020ec2..90d4d145 100644 --- a/test/Exceptionless.MessagePack.Tests/MessagePackStorageSerializerTests.cs +++ b/test/Exceptionless.MessagePack.Tests/MessagePackStorageSerializerTests.cs @@ -5,13 +5,8 @@ namespace Exceptionless.MessagePack.Tests { public class MessagePackStorageSerializerTests : StorageSerializerTestBase { - protected override void Initialize(IDependencyResolver resolver) { - base.Initialize(resolver); - resolver.Register(new MessagePackStorageSerializer(resolver)); - } - - protected override IStorageSerializer GetSerializer(IDependencyResolver resolver) { - return resolver.Resolve(); + public MessagePackStorageSerializerTests() { + Resolver.Register(new MessagePackStorageSerializer(Resolver)); } [Fact] diff --git a/test/Exceptionless.TestHarness/Serializer/StorageSerializerTestBase.cs b/test/Exceptionless.TestHarness/Serializer/StorageSerializerTestBase.cs index 224674d4..39bb0db0 100644 --- a/test/Exceptionless.TestHarness/Serializer/StorageSerializerTestBase.cs +++ b/test/Exceptionless.TestHarness/Serializer/StorageSerializerTestBase.cs @@ -13,21 +13,16 @@ namespace Exceptionless.Tests.Serializer { public abstract class StorageSerializerTestBase { - private readonly IDependencyResolver _resolver; + protected readonly IDependencyResolver Resolver = new DefaultDependencyResolver(); + public StorageSerializerTestBase() { - _resolver = new DefaultDependencyResolver(); - _resolver.Register(); - _resolver.Register(); - _resolver.Register(); - _resolver.Register(); - _resolver.Register(new ExceptionlessConfiguration(_resolver)); - Initialize(_resolver); + Resolver.Register(); + Resolver.Register(); + Resolver.Register(); + Resolver.Register(); + Resolver.Register(new ExceptionlessConfiguration(Resolver)); } - protected virtual void Initialize(IDependencyResolver resolver) { } - - protected abstract IStorageSerializer GetSerializer(IDependencyResolver resolver); - private Event CreateSimpleEvent() { var ev= new Event { Date = DateTime.Now, @@ -47,7 +42,7 @@ private Event CreateSimpleEvent() { } private void AssertEventSerialize(Event evt) { - var serializer = GetSerializer(_resolver); + var serializer = Resolver.Resolve(); Event newEvent; using (var memory = new MemoryStream()) { serializer.Serialize(evt, memory); @@ -55,9 +50,9 @@ private void AssertEventSerialize(Event evt) { newEvent = serializer.Deserialize(memory); } - var jsonSerializer = _resolver.GetJsonSerializer(); - var expected = jsonSerializer.Serialize(evt); - var actual = jsonSerializer.Serialize(newEvent); + var jsonSerializer = Resolver.GetJsonSerializer(); + string expected = jsonSerializer.Serialize(evt); + string actual = jsonSerializer.Serialize(newEvent); Assert.Equal(expected, actual); } @@ -78,13 +73,13 @@ public virtual void CanSerializeSimpleDataValues() { public virtual void CanSerializeTags() { var evt = CreateSimpleEvent(); - evt.AddTags("Critial", "Startup", "AspNetCore"); + evt.AddTags("Critical", "Startup", "AspNetCore"); AssertEventSerialize(evt); } public virtual void CanSerializeEnvironmentInfo() { var evt = CreateSimpleEvent(); - evt.Data[Event.KnownDataKeys.EnvironmentInfo] = _resolver.Resolve().GetEnvironmentInfo(); + evt.Data[Event.KnownDataKeys.EnvironmentInfo] = Resolver.Resolve().GetEnvironmentInfo(); AssertEventSerialize(evt); } @@ -142,7 +137,7 @@ public virtual void CanSerializeManualStackingInfo() { } public virtual void CanSerializeSimpleError() { - var client = new ExceptionlessClient(new ExceptionlessConfiguration(_resolver)); + var client = new ExceptionlessClient(new ExceptionlessConfiguration(Resolver)); var exception = new ArgumentException("The argument cannot be null or empty", "value"); var evt = CreateSimpleEvent(); @@ -151,7 +146,7 @@ public virtual void CanSerializeSimpleError() { } public virtual void CanSerializeError() { - var client = new ExceptionlessClient(new ExceptionlessConfiguration(_resolver)); + var client = new ExceptionlessClient(new ExceptionlessConfiguration(Resolver)); var exception = new ArgumentException("The argument cannot be null or empty", "value"); var evt = CreateSimpleEvent(); diff --git a/test/Exceptionless.Tests/Plugins/PluginTestBase.cs b/test/Exceptionless.Tests/Plugins/PluginTestBase.cs index c8a87041..1e2de303 100644 --- a/test/Exceptionless.Tests/Plugins/PluginTestBase.cs +++ b/test/Exceptionless.Tests/Plugins/PluginTestBase.cs @@ -59,7 +59,7 @@ protected struct TestStruct { public int Id { get; set; } } - public class MyApplicationException : Exception { + public sealed class MyApplicationException : Exception { public MyApplicationException(string message) : base(message) { SetsDataProperty = Data; } diff --git a/test/Exceptionless.Tests/Serializer/JsonStorageSerializerTests.cs b/test/Exceptionless.Tests/Serializer/JsonStorageSerializerTests.cs index 91d0627e..7db623f6 100644 --- a/test/Exceptionless.Tests/Serializer/JsonStorageSerializerTests.cs +++ b/test/Exceptionless.Tests/Serializer/JsonStorageSerializerTests.cs @@ -4,13 +4,8 @@ namespace Exceptionless.Tests.Serializer { public class JsonStorageSerializerTests : StorageSerializerTestBase { - protected override void Initialize(IDependencyResolver resolver) { - base.Initialize(resolver); - resolver.Register(); - } - - protected override IStorageSerializer GetSerializer(IDependencyResolver resolver) { - return resolver.Resolve(); + public JsonStorageSerializerTests() { + Resolver.Register(); } [Fact(Skip = "The json serializer deserialize anonymous(object) types as dictionary.")]