3
我想知道什么是编写Microsoft Visual Studio单元测试Assert类的自定义扩展方法的最佳方法。为VS UT Assert类创建自定义扩展方法的最佳方式是什么?
我想知道什么是编写Microsoft Visual Studio单元测试Assert类的自定义扩展方法的最佳方法。为VS UT Assert类创建自定义扩展方法的最佳方式是什么?
如果您指的是这个Assert类,那么您不能添加扩展方法。扩展方法只能应用于对象实例。由于这个类是静态的,它永远不会被实例化。
你可以添加自己的自定义断言类型的类像这样虽然:
public static class MyAssert {
public static void AreEqual(object expected, object actual) {
// TODO: throw if not equal
}
}
我写我自己的可扩展的包装上断言的前头网站。源代码可以在这里找到:https://github.com/bbraithwaite/MSTestExtensions –