From 921d1e99882b694d0399894fa3fd7aaca5f93a8f Mon Sep 17 00:00:00 2001
From: Christian Kadluba <10721825+ckadluba@users.noreply.github.com>
Date: Wed, 28 Aug 2024 12:09:09 +0200
Subject: [PATCH] Fixed vulnerability by updating xunit
* Fixed vulnerability by updating xunit to 2.9.0.
* Fixed new warnings in test code.
Related issue: #544
Related Work Items: #5
---
Directory.Packages.props | 4 +--
.../Sinks/MSSqlServer/MSSqlServerSinkTests.cs | 2 +-
.../Platform/SqlBulkBatchWriterTests.cs | 36 +++++++++----------
.../Platform/SqlInsertStatementWriterTests.cs | 2 +-
.../Sinks/MSSqlServer/SqlServerColumnTests.cs | 2 +-
5 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 8869cf59..1a21d3fc 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -15,8 +15,8 @@
-
-
+
+
diff --git a/test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/MSSqlServerSinkTests.cs b/test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/MSSqlServerSinkTests.cs
index fa91f233..ca886b17 100644
--- a/test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/MSSqlServerSinkTests.cs
+++ b/test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/MSSqlServerSinkTests.cs
@@ -162,7 +162,7 @@ public async Task EmitBatchAsyncCallsSqlLogEventWriter()
});
// Act
- await _sut.EmitBatchAsync(logEvents).ConfigureAwait(false);
+ await _sut.EmitBatchAsync(logEvents);
// Assert
_sqlBulkBatchWriter.Verify(w => w.WriteBatch(It.IsAny>(), _dataTable), Times.Once);
diff --git a/test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/Platform/SqlBulkBatchWriterTests.cs b/test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/Platform/SqlBulkBatchWriterTests.cs
index d7d83a4f..2de6712e 100644
--- a/test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/Platform/SqlBulkBatchWriterTests.cs
+++ b/test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/Platform/SqlBulkBatchWriterTests.cs
@@ -72,7 +72,7 @@ public async Task WriteBatchCallsLogEventDataGeneratorGetColumnsAndValuesForEach
var logEvents = CreateLogEvents();
// Act
- await _sut.WriteBatch(logEvents, _dataTable).ConfigureAwait(false);
+ await _sut.WriteBatch(logEvents, _dataTable);
// Assert
_logEventDataGeneratorMock.Verify(c => c.GetColumnsAndValues(logEvents[0]), Times.Once);
@@ -86,7 +86,7 @@ public async Task WriteBatchCallsSqlConnectionFactoryCreate()
var logEvents = CreateLogEvents();
// Act
- await _sut.WriteBatch(logEvents, _dataTable).ConfigureAwait(false);
+ await _sut.WriteBatch(logEvents, _dataTable);
// Assert
_sqlConnectionFactoryMock.Verify(f => f.Create(), Times.Once);
@@ -99,7 +99,7 @@ public async Task WriteBatchCallsSqlConnectionWrapperOpenAsync()
var logEvents = CreateLogEvents();
// Act
- await _sut.WriteBatch(logEvents, _dataTable).ConfigureAwait(false);
+ await _sut.WriteBatch(logEvents, _dataTable);
// Assert
_sqlConnectionWrapperMock.Verify(c => c.OpenAsync(), Times.Once);
@@ -113,7 +113,7 @@ public async Task WriteBatchCallsSqlConnectionWrappeCreateSqlBulkCopy()
var expectedDestinationTableName = string.Format(CultureInfo.InvariantCulture, "[{0}].[{1}]", _schemaName, _tableName);
// Act
- await _sut.WriteBatch(logEvents, _dataTable).ConfigureAwait(false);
+ await _sut.WriteBatch(logEvents, _dataTable);
// Assert
_sqlConnectionWrapperMock.Verify(c => c.CreateSqlBulkCopy(false, expectedDestinationTableName), Times.Once);
@@ -128,7 +128,7 @@ public async Task WriteBatchCallsSqlConnectionWrappeCreateSqlBulkCopyWithDisable
var sut = new SqlBulkBatchWriter(_tableName, _schemaName, true, _sqlConnectionFactoryMock.Object, _logEventDataGeneratorMock.Object);
// Act
- await sut.WriteBatch(logEvents, _dataTable).ConfigureAwait(false);
+ await sut.WriteBatch(logEvents, _dataTable);
// Assert
_sqlConnectionWrapperMock.Verify(c => c.CreateSqlBulkCopy(true, expectedDestinationTableName), Times.Once);
@@ -145,7 +145,7 @@ public async Task WriteBatchCallsSqlBulkCopyWrapperAddSqlBulkCopyColumnMappingFo
_dataTable.Columns.Add(new DataColumn(column2Name));
// Act
- await _sut.WriteBatch(logEvents, _dataTable).ConfigureAwait(false);
+ await _sut.WriteBatch(logEvents, _dataTable);
// Assert
_sqlBulkCopyWrapper.Verify(c => c.AddSqlBulkCopyColumnMapping(column1Name, column1Name), Times.Once);
@@ -159,7 +159,7 @@ public async Task WriteBatchCallsSqlBulkCopyWrapperWriteToServerAsync()
var logEvents = CreateLogEvents();
// Act
- await _sut.WriteBatch(logEvents, _dataTable).ConfigureAwait(false);
+ await _sut.WriteBatch(logEvents, _dataTable);
// Assert
_sqlBulkCopyWrapper.Verify(c => c.WriteToServerAsync(_dataTable), Times.Once);
@@ -172,14 +172,14 @@ public async Task WriteBatchClearsDataTable()
var logEvents = CreateLogEvents();
// Act
- await _sut.WriteBatch(logEvents, _dataTable).ConfigureAwait(false);
+ await _sut.WriteBatch(logEvents, _dataTable);
// Assert
Assert.Empty(_dataTable.Rows);
}
[Fact]
- public void WriteBatchRethrowsIfLogEventDataGeneratorMockGetColumnsAndValuesThrows()
+ public async Task WriteBatchRethrowsIfLogEventDataGeneratorMockGetColumnsAndValuesThrows()
{
// Arrange
_logEventDataGeneratorMock.Setup(d => d.GetColumnsAndValues(It.IsAny()))
@@ -187,33 +187,33 @@ public void WriteBatchRethrowsIfLogEventDataGeneratorMockGetColumnsAndValuesThro
var logEvents = CreateLogEvents();
// Act + assert
- Assert.ThrowsAsync(() => _sut.WriteBatch(logEvents, _dataTable));
+ await Assert.ThrowsAsync(() => _sut.WriteBatch(logEvents, _dataTable));
}
[Fact]
- public void WriteBatchRethrowsIfSqlConnectionFactoryCreateThrows()
+ public async Task WriteBatchRethrowsIfSqlConnectionFactoryCreateThrows()
{
// Arrange
_sqlConnectionFactoryMock.Setup(f => f.Create()).Callback(() => throw new InvalidOperationException());
var logEvents = CreateLogEvents();
// Act + assert
- Assert.ThrowsAsync(() => _sut.WriteBatch(logEvents, _dataTable));
+ await Assert.ThrowsAsync(() => _sut.WriteBatch(logEvents, _dataTable));
}
[Fact]
- public void WriteBatchRethrowsIfSqlConnectionOpenAsyncThrows()
+ public async Task WriteBatchRethrowsIfSqlConnectionOpenAsyncThrows()
{
// Arrange
_sqlConnectionWrapperMock.Setup(c => c.OpenAsync()).Callback(() => throw new InvalidOperationException());
var logEvents = CreateLogEvents();
// Act + assert
- Assert.ThrowsAsync(() => _sut.WriteBatch(logEvents, _dataTable));
+ await Assert.ThrowsAsync(() => _sut.WriteBatch(logEvents, _dataTable));
}
[Fact]
- public void WriteBatchRethrowsIfSqlBulkCopyWriterAddSqlBulkCopyColumnMappingThrows()
+ public async Task WriteBatchRethrowsIfSqlBulkCopyWriterAddSqlBulkCopyColumnMappingThrows()
{
// Arrange
_sqlBulkCopyWrapper.Setup(c => c.AddSqlBulkCopyColumnMapping(It.IsAny(), It.IsAny()))
@@ -222,11 +222,11 @@ public void WriteBatchRethrowsIfSqlBulkCopyWriterAddSqlBulkCopyColumnMappingThro
_dataTable.Columns.Add(new DataColumn("ColumnName"));
// Act + assert
- Assert.ThrowsAsync(() => _sut.WriteBatch(logEvents, _dataTable));
+ await Assert.ThrowsAsync(() => _sut.WriteBatch(logEvents, _dataTable));
}
[Fact]
- public void WriteBatchRethrowsIfSqlBulkCopyWriterWriteToServerAsyncThrows()
+ public async Task WriteBatchRethrowsIfSqlBulkCopyWriterWriteToServerAsyncThrows()
{
// Arrange
_sqlBulkCopyWrapper.Setup(c => c.WriteToServerAsync(It.IsAny()))
@@ -234,7 +234,7 @@ public void WriteBatchRethrowsIfSqlBulkCopyWriterWriteToServerAsyncThrows()
var logEvents = CreateLogEvents();
// Act + assert
- Assert.ThrowsAsync(() => _sut.WriteBatch(logEvents, _dataTable));
+ await Assert.ThrowsAsync(() => _sut.WriteBatch(logEvents, _dataTable));
}
private static List CreateLogEvents()
diff --git a/test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/Platform/SqlInsertStatementWriterTests.cs b/test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/Platform/SqlInsertStatementWriterTests.cs
index dac3704b..34e9d9db 100644
--- a/test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/Platform/SqlInsertStatementWriterTests.cs
+++ b/test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/Platform/SqlInsertStatementWriterTests.cs
@@ -192,7 +192,7 @@ public async Task WriteBatchCallsLogEventDataGeneratorGetColumnsAndValuesForEach
var logEvents = CreateLogEvents();
// Act
- await _sut.WriteBatch(logEvents).ConfigureAwait(false);
+ await _sut.WriteBatch(logEvents);
// Assert
_logEventDataGeneratorMock.Verify(c => c.GetColumnsAndValues(logEvents[0]), Times.Once);
diff --git a/test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/SqlServerColumnTests.cs b/test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/SqlServerColumnTests.cs
index c1f5526c..a06eb028 100644
--- a/test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/SqlServerColumnTests.cs
+++ b/test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/SqlServerColumnTests.cs
@@ -33,7 +33,7 @@ public void StoresPropertyName()
// Assert
Assert.Equal(propertyName, sut.PropertyName);
- Assert.Equal(1, sut.PropertyNameHierarchy.Count);
+ Assert.Single(sut.PropertyNameHierarchy);
Assert.Equal(propertyName, sut.PropertyNameHierarchy[0]);
Assert.False(sut.HasHierarchicalPropertyName);
}