Question

I have a matrix struct, and custom comparison methods:

static bool AlmostEquals(ref Matrix a, ref Matrix b);
static bool AlmostEquals(ref Matrix a, ref Matrix b, float epsilon);

What's the correct call to Fluent Assertion to get this comparison to work?

Was it helpful?

Solution

AlmostEquals(ref a, ref b).Should().BeTrue("because matrices a and b are almost equal");
AlmostEquals(ref a, ref b, epsilon).Should().BeTrue("because matrices a and b are almost equal");

You can even add some info about the matrices and epsilon into the message like

AlmostEquals(ref a, ref b, epsilon).Should().BeTrue("because matrices a and b are almost equal with {0} precision", epsilon);

May be you would need to introduce a local bool variable to make the FluentAssertions work (I don't have it installed) and assign it a value of AlmostEquals and then run assertion against the boolean variable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top