So I want to use custom equivalency criterion in Fluid Assertions (.NET) for collection elements. When applied to class property this works perfectly:
var actual = new Dto() {Value = 1.11};
var expected = new Dto() {Value = 1.1};
actual.ShouldBeEquivalentTo(expected, options =>
options.Using<double>(x =>
x.Subject.Should().BeApproximately(
x.Expectation, 0.2))
.WhenTypeIs<double>());
However, when I try to apply the same assertion to colleciton members, I get a failure:
var actual = new [] {1.11};
var expected = new[] {1.1};
...
I get this error:
Expected item[0] to be 1.1, but found 1.11.
With configuration:
- Use declared types and members
- Compare enums by value
- Match member by name (or throw)
- Invoke Action when info.RuntimeType.IsSameOrInherits(System.Double)
- Be strict about the order of items in byte arrays`
Same thing happens when using ShouldAllBeEquivalentTo
. Is this by design? Is this a bug? Am I missing a trick here?
Aucun commentaire:
Enregistrer un commentaire