1
我有一個矩陣結構,以及自定義比較方法流利斷言定義比較:與裁判爭論
static bool AlmostEquals(ref Matrix a, ref Matrix b);
static bool AlmostEquals(ref Matrix a, ref Matrix b, float epsilon);
什麼是流利的斷言正確的調用來獲取這個比較工作?
我有一個矩陣結構,以及自定義比較方法流利斷言定義比較:與裁判爭論
static bool AlmostEquals(ref Matrix a, ref Matrix b);
static bool AlmostEquals(ref Matrix a, ref Matrix b, float epsilon);
什麼是流利的斷言正確的調用來獲取這個比較工作?
AlmostEquals(ref a, ref b).Should().BeTrue("because matrices a and b are almost equal");
AlmostEquals(ref a, ref b, epsilon).Should().BeTrue("because matrices a and b are almost equal");
你甚至可以添加關於矩陣和Epsilon一些信息到消息像
AlmostEquals(ref a, ref b, epsilon).Should().BeTrue("because matrices a and b are almost equal with {0} precision", epsilon);
可能是你需要引入一個局部布爾變量,使FluentAssertions工作(我不安裝它)併爲其分配值AlmostEquals,然後對布爾變量運行斷言。