fluentassertions / fluentassertions/fluentassertions.datasets

Comparing datatables with dbnull in expectation doesn't cause test to fail when subject has a value

未关闭
#2 9 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug
主要语言
C#
星标
1
派生
4
平均合并
8 小时 19 分钟
30 天内合并 PR
3

描述

### Description

Comparing DataTables where a column in the expectation containing a dbnull value passes comparison regardless of the value in the same column in the subject.

### Complete minimal example reproducing the issue

```csharp
// Arrange
var expected = new DataTable();
expected.Columns.AddRange(new[]
{
new DataColumn("Column1", typeof(string)),
new DataColumn("Column2", typeof(string)),
new DataColumn("Column3", typeof(string))
});

expected.Rows.Add("test", null, "1" );

// Act
var actual = new DataTable();
actual.Columns.AddRange(new[]
{
new DataColumn("Column1", typeof(string)),
new DataColumn("Column2", typeof(string)),
new DataColumn("Column3", typeof(string))
});
actual.Rows.Add("test", "fail", "1");

// Assert
actual.Should().BeEquivalentTo(expected);
```

### Expected behavior:

The test to fail because "Column2" in the expectation is null while it has a value of "fail" in the subject

### Actual behavior:

The test passes. Reversing the order leads to the test failing as expected, i.e.,

```csharp
// Assert
expected.Should().BeEquivalentTo(actual);
```
fails.

### Versions

* Which version of Fluent Assertions are you using? 6.7.0
* Which .NET runtime and version are you targeting? .NET 6

### Additional Information

Any additional information, configuration or data that might be necessary to reproduce the issue.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。