diff --git a/test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/MSSqlServerAuditSinkTests.cs b/test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/MSSqlServerAuditSinkTests.cs index 4afebc9..33389ad 100644 --- a/test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/MSSqlServerAuditSinkTests.cs +++ b/test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/MSSqlServerAuditSinkTests.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Data; using Moq; using Serilog.Events; using Serilog.Parsing; @@ -157,6 +156,16 @@ public void EmitCallsSqlLogEventWriter() _sqlLogEventWriter.Verify(w => w.WriteEvent(logEvent), Times.Once); } + [Fact] + public void OnDisposeDisposesSqlLogEventWriterDependency() + { + // Arrange + act + using (new MSSqlServerAuditSink(_sinkOptions, _columnOptions, _sinkDependencies)) { } + + // Assert + _sqlLogEventWriter.Verify(w => w.Dispose(), Times.Once); + } + private void SetupSut(bool autoCreateSqlDatabase = false, bool autoCreateSqlTable = false) { _sinkOptions.AutoCreateSqlDatabase = autoCreateSqlDatabase; diff --git a/test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/MSSqlServerSinkTests.cs b/test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/MSSqlServerSinkTests.cs index 9c2b9a6..f6a6b01 100644 --- a/test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/MSSqlServerSinkTests.cs +++ b/test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/MSSqlServerSinkTests.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Data; using System.Threading.Tasks; using Moq; using Serilog.Events; @@ -185,6 +184,26 @@ public void OnEmptyBatchAsyncReturnsCompletedTask() Assert.True(task.IsCompleted); } + [Fact] + public void OnDisposeDisposesSqlBulkBatchWriterDependency() + { + // Arrange + act + using (new MSSqlServerSink(_sinkOptions, _sinkDependencies)) { } + + // Assert + _sqlBulkBatchWriter.Verify(w => w.Dispose(), Times.Once); + } + + [Fact] + public void OnDisposeDisposesSqlLogEventWriterDependency() + { + // Arrange + act + using (new MSSqlServerSink(_sinkOptions, _sinkDependencies)) { } + + // Assert + _sqlLogEventWriter.Verify(w => w.Dispose(), Times.Once); + } + private void SetupSut( bool autoCreateSqlDatabase = false, bool autoCreateSqlTable = false,