1

I have this test method failed even if debugger show correct value. Why this test is not passing then?

 [TestMethod]
    public void Should_60Deegrees_ForArcCosOfHalf()
    {
        var deegrees = (Math.Acos(0.5) * 180 / Math.PI);
        Assert.AreEqual(60, deegrees);
    }
S3ball
  • 11
  • 1
  • Probably because of floating-point arithmetic. You should not compare doubles via equality but with a tolerance. Btw.: what are you testing here? – MakePeaceGreatAgain Dec 15 '16 at 13:18
  • Thanks! Math.Round method helps. This is for testing angle calculation using altitude and distance of gps paths. I just removed objects from test method to explain the issue. – S3ball Dec 15 '16 at 13:29

0 Answers0