What is the difference between:
subject.Should().Be(expected)
subject.Should().Equals(expected)
I always use Be()
, but I now have a testcase where Be()
gives a different result, then Equals()
. My testcase involves a struct and comparing it with the default of that struct.
MyStruct subject = new MyStruct("value");
Assert.Equal(default, subject); // xUnit Assert => works
Assert.Equal(default(MyStruct), (object)subject); // xUnit Assert => works
subject.Should().Equals(default); // works
subject.Should().Be(default(MyStruct)); // FAILS!
Are Be()
and Equal()
the same and is this a bug in Fluent Assertions? Or are they asserting different things?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.