Skip to content

Commit

Permalink
Fixed vulnerability by updating xunit
Browse files Browse the repository at this point in the history
* Fixed vulnerability by updating xunit to 2.9.0.
* Fixed new warnings in test code.

Related issue: serilog-mssql#544

Related Work Items: #5
  • Loading branch information
ckadluba committed Aug 28, 2024
1 parent 6798ef6 commit 921d1e9
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<PackageVersion Include="FluentAssertions" Version="6.7.0" />
<PackageVersion Include="Dapper.StrongName" Version="2.0.123" />
<PackageVersion Include="Moq" Version="4.18.2" />
<PackageVersion Include="xunit" Version="2.4.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5" />
<PackageVersion Include="xunit" Version="2.9.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="Serilog" Version="3.1.1" />
<PackageVersion Include="Serilog.Extensions.Hosting" Version="5.0.1" />
<PackageVersion Include="Serilog.Settings.Configuration" Version="3.4.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<IEnumerable<LogEvent>>(), _dataTable), Times.Once);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -172,48 +172,48 @@ 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<LogEvent>()))
.Callback(() => throw new InvalidOperationException());
var logEvents = CreateLogEvents();

// Act + assert
Assert.ThrowsAsync<InvalidOperationException>(() => _sut.WriteBatch(logEvents, _dataTable));
await Assert.ThrowsAsync<InvalidOperationException>(() => _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<InvalidOperationException>(() => _sut.WriteBatch(logEvents, _dataTable));
await Assert.ThrowsAsync<InvalidOperationException>(() => _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<InvalidOperationException>(() => _sut.WriteBatch(logEvents, _dataTable));
await Assert.ThrowsAsync<InvalidOperationException>(() => _sut.WriteBatch(logEvents, _dataTable));
}

[Fact]
public void WriteBatchRethrowsIfSqlBulkCopyWriterAddSqlBulkCopyColumnMappingThrows()
public async Task WriteBatchRethrowsIfSqlBulkCopyWriterAddSqlBulkCopyColumnMappingThrows()
{
// Arrange
_sqlBulkCopyWrapper.Setup(c => c.AddSqlBulkCopyColumnMapping(It.IsAny<string>(), It.IsAny<string>()))
Expand All @@ -222,19 +222,19 @@ public void WriteBatchRethrowsIfSqlBulkCopyWriterAddSqlBulkCopyColumnMappingThro
_dataTable.Columns.Add(new DataColumn("ColumnName"));

// Act + assert
Assert.ThrowsAsync<InvalidOperationException>(() => _sut.WriteBatch(logEvents, _dataTable));
await Assert.ThrowsAsync<InvalidOperationException>(() => _sut.WriteBatch(logEvents, _dataTable));
}

[Fact]
public void WriteBatchRethrowsIfSqlBulkCopyWriterWriteToServerAsyncThrows()
public async Task WriteBatchRethrowsIfSqlBulkCopyWriterWriteToServerAsyncThrows()
{
// Arrange
_sqlBulkCopyWrapper.Setup(c => c.WriteToServerAsync(It.IsAny<DataTable>()))
.Callback(() => throw new InvalidOperationException());
var logEvents = CreateLogEvents();

// Act + assert
Assert.ThrowsAsync<InvalidOperationException>(() => _sut.WriteBatch(logEvents, _dataTable));
await Assert.ThrowsAsync<InvalidOperationException>(() => _sut.WriteBatch(logEvents, _dataTable));
}

private static List<LogEvent> CreateLogEvents()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 921d1e9

Please sign in to comment.