-
Notifications
You must be signed in to change notification settings - Fork 731
Closed
Labels
Description
Description
Different results are being reported when using ContainEquivalentOf against an instance of SqlParameter with a DBNull.Value. When I run this in Debug build the test passes, when I switch to Release build it fails.
Complete minimal example reproducing the issue
Please consider the following
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using FluentAssertions;
namespace UnitTestProject1
{
public class Foo
{
public string Bar => "FOOBAR";
public List<SqlParameter> Parameters => new List<SqlParameter> {
new SqlParameter("@inBar", DBNull.Value),
new SqlParameter("@inSettings", Bar),
};
}
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
var sut = new Foo();
sut.Parameters.Should().ContainEquivalentOf(new SqlParameter("@inBar", DBNull.Value));
if (!string.IsNullOrEmpty(sut.Bar))
sut.Parameters.Should().ContainEquivalentOf(new SqlParameter("@inSettings", sut.Bar));
}
}
}Expected behavior:
Debug and Release build should either both pass or fail, I'm not sure if the intention is to fail this or if it should pass, it would be nice if it did pass since it is consistent with the way parameter verification is done elsewhere.
Actual behavior:
Debug build passes while Release build fails
Versions
- FluentAssertions 6.3.0
- .NET Framework 8.0 and 4.7.2
Additional Information
Please note that if I switch the order of the assertions and run the if statement before the DBNull assertion this will pass in both builds.