testdelegateまたはdelegateを受け取り、パラメーターをdelegateオブジェクトに渡すメソッドを作成しようとしています。これは、すべてが同じパラメーター(ID)をとるコントローラーのメソッドのテストを作成しており、すべてのコントローラーメソッドのテストを作成したくないためです。
私が持っているコード:
protected void AssertThrows_NullReference_Og_InvalidOperation(TestDelegate delegateMethod)
{
Assert.Throws<NullReferenceException>(delegateMethod);
Assert.Throws<InvalidOperationException>(delegateMethod);
Assert.Throws<InvalidOperationException>(delegateMethod);
}
私がしたいこと:
protected void AssertThrows_NullReference_Og_InvalidOperation(TestDelegate delegateMethod)
{
Assert.Throws<NullReferenceException>(delegateMethod(null));
Assert.Throws<InvalidOperationException>(delegateMethod(string.Empty));
Assert.Throws<InvalidOperationException>(delegateMethod(" "));
}
編集:コントローラーに戻り値があることを忘れました。したがって、アクションは使用できません。