Visual Studio Unit Test: why test run inconclusive whereas testing same float values?

erm, because you told it to be?

Assert.Inconclusive("Verify the correctness of this test method.");

Now you have your AreEqual, you should be able to remove this Inconclusive

Any failure during a test (not including exceptions that you intentionally handle) is generally terminal, but any assert that passes (like the AreEqual here) just keeps on running. So the first test passes, then the last line flags it as inconclusive.


Even when you've removed the Assert.Inconclusive you still might have problems.

You're testing the equality of two floating point numbers and in general with calculated values you'll never get them exactly the same. You need to check that the actual value is within an acceptable range of the expected value:

Math.Abs(actual - expected) < 0.00001;

for example.

Your Assert.AreEqual(expected, actual); works in this case because you are assigning the same value to both variables.


Doesn't that just mean that the AreEqual passed, which meant it called Assert.Inconclusive, leading to a result of inconclusive?

From the docs:

Similar to Fail in that it indicates an assertion is inconclusive without checking any conditions.

If you don't want the result to be inclusive, remove the call to Assert.Inconclusive :)