MbUnitの:ダブルスを比較するための最もエレガントな方法はありますか?

StackOverflow https://stackoverflow.com/questions/727260

  •  05-09-2019
  •  | 
  •  

質問

コード

Assert.AreEqual (9.97320998018748d, observerPosition.CenterLongitude);

生成

Expected Value & Actual Value : 9.97320998018748
Remark : Both values look the same when formatted but they 
are distinct instances.

MbUnitの3.0に平等のための2つのdoubleを比較するための最もエレガントな方法は何ですか?私は自分自身をそれらを切り上げる可能性が知っているが、いくつかMbUnitのは、このために構築がありますか?

UPDATE:私は私の現在の「回避策」は非エレガントであると考えます:

Assert.LessThan(
   Math.Abs(9.97320998018748d - observerPosition.CenterLongitude),
   0.0000001);
役に立ちましたか?

解決

AreApproximatelyEqual には "MbUnitのは、このために構築" のようです。

  

実際の値ことを確認   約いくつかの予想等しいです   指定されたデルタ内に値ます。

これは Assert.AreEqual(double expected, double actual, double delta)する

に似ているようです
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top