I have a class Vector3D
that has the properties X
, Y
and Z
of type double (it also has other properties such as Magnitude
).
What is the best way of approximately comparing all the properties or a selection of the properties at a given precision using Fluent Assertions?
Currently I have been doing it like this:
calculated.X.Should().BeApproximately(expected.X, precision);
calculated.Y.Should().BeApproximately(expected.Y, precision);
calculated.Z.Should().BeApproximately(expected.Z, precision);
Is there a single line approach that will achieve the same thing? Such as using ShouldBeEquivalentTo
, or does this require constructing a generic extension method that allows properties to be included / excluded?
.When
has to be used in this particular case instead of.Including
to specify which properties are used for the equivalence test? – Ashok