I’m working on unit-tests for an application and below is a unit-test I just cant figure out why it fails.
The test result should be that “isosceles” is true and “equalateral” and “scalene” is false, which Console.WriteLine shows that they actually are, but by some strange reason the test fails anyhow. What am I doing wrong here? Thanks in advance.
I’m using the MSTest framework.
public void isIsosceles()
{
Triangle triangle = new Triangle(2, 2, 5);
var isosceles = triangle.isIsosceles();
var equalateral = triangle.isEquilateral();
var scalene = triangle.isScalene();
Console.WriteLine(isosceles); // True
Console.WriteLine(equalateral); // False
Console.WriteLine(scalene); // False
Assert.IsTrue(true, "Test Isosceles", isosceles);
Assert.IsTrue(false, "Test Equalateral", equalateral); // Fails, why?
Assert.IsTrue(false, "Test Scalene", scalene); // Fails, why?
}
You’re mis-calling
IsTrue.The first parameter is the boolean to test:
You can also call
AreEqual: