Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ protected virtual void Dispose(bool disposing)
{
if (disposing)
{
_sqlBulkBatchWriter.Dispose();
_sqlLogEventWriter.Dispose();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Data;
using Moq;
using Serilog.Events;
using Serilog.Parsing;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Threading.Tasks;
using Moq;
using Serilog.Events;
Expand Down Expand Up @@ -173,7 +172,7 @@ public async Task EmitBatchAsyncWithUseSqlBulkCopyFalseCallsSqlLogEventWriter()
}

[Fact]
public void OnEmpytBatchAsyncReturnsCompletedTask()
public void OnEmptyBatchAsyncReturnsCompletedTask()
{
// Arrange
SetupSut();
Expand All @@ -185,6 +184,26 @@ public void OnEmpytBatchAsyncReturnsCompletedTask()
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,
Expand Down
Loading