我有一堆運算符重載的一類:通拉姆達參數化NUnit測試
public static double[,] operator +(Matrix matrix, double[,] array)
public static double[,] operator -(Matrix matrix, double[,] array)
public static double[,] operator *(Matrix matrix, double[,] array)
對於所有的人我想測試操作數爲空。我有,一個NUnit
測試:
public void MatrixOperatorOperandIsNullThrows(Func<Matrix, double[,], double[,]> op)
{
Matrix m = null;
var right = new double[,] {{1, 1}, {1, 1}};
Assert.Throws<ArgumentException>(() => op(m, right));
}
我如何可以通過爲每個操作員像(l,r) => l + r
拉姆達?
我最好在哪裏打電話?在「TextFixture」的構造函數中?我也使用Resharper來運行測試。它能以這種方式處理它們嗎? –
@AndreyErmakov:每個操作員都有一個單獨的測試方法。 – SLaks