The code
Assert.AreEqual (9.97320998018748d, observerPosition.CenterLongitude);
produces
Expected Value & Actual Value : 9.97320998018748
Remark : Both values look the same when formatted but they
are distinct instances.
What is the most elegant way to compare two doubles for equality in MbUnit 3.0? I know I could round them up myself, but is there some MbUnit construct for this?
在MbUnit 3.0中比较两个双重同等的最优雅的方法是什么?我知道我可以自己围绕它们,但是有一些MbUnit构造吗?
UPDATE: I consider my current "workaround" to be non-elegant:
更新:我认为我目前的“解决方法”不优雅:
Assert.LessThan(
Math.Abs(9.97320998018748d - observerPosition.CenterLongitude),
0.0000001);
1 个解决方案
#1
AreApproximatelyEqual
seems to be the "MbUnit construct for this":
AreApproximatelyEqual似乎是“MbUnit构造的”:
Verifies that an actual value approximately equals some expected value to within a specified delta.
验证实际值是否大约等于指定增量内的某些预期值。
This seems to be similar to Assert.AreEqual(double expected, double actual, double delta)
这似乎与Assert.AreEqual类似(双重预期,双重实际,双三角形)
#1
AreApproximatelyEqual
seems to be the "MbUnit construct for this":
AreApproximatelyEqual似乎是“MbUnit构造的”:
Verifies that an actual value approximately equals some expected value to within a specified delta.
验证实际值是否大约等于指定增量内的某些预期值。
This seems to be similar to Assert.AreEqual(double expected, double actual, double delta)
这似乎与Assert.AreEqual类似(双重预期,双重实际,双三角形)