什么是“升级路径”?来自断言.AssertEquals?
我继承了一些单元测试代码,该代码给我一个弃用警告,因为它使用“Assertion.AssertEquals”:
警告CS0618:'NUnit.Framework.Assertion'已过时:'使用Assert类代替'
但是,我看不到我应该使用 Assert 类中明显的方法吗?
AssertEquals 采用两个对象和一条消息,可用于在出现故障时报告错误。例如,
Assertion.AssertEquals(
"Enqueuing first item should set count to 1",
1, pq.Count);
Assert 类的等效方法是什么?
I've inherited some unit test code which is giving me a deprecation warning because it uses "Assertion.AssertEquals":
warning CS0618: 'NUnit.Framework.Assertion' is obsolete: 'Use Assert class instead'
However, I can't see the obvious method in the Assert class that I should be using instead?
AssertEquals takes two objects and a message that can be used to report the error if there's a failure. e.g.
Assertion.AssertEquals(
"Enqueuing first item should set count to 1",
1, pq.Count);
What's the equivalent method on the Assert class?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
答案 Jon Skeet 提出了所谓的观点“经典”模型,而 John Gietzen 的答案是指“基于约束”的模型。两者都是正确的,并且都提供了在失败的情况下传递消息的可能性。
所以让我总结一下:
“经典”模型
“基于约束”模型
我更喜欢后者,因为它读起来更像一个句子。
The answer Jon Skeet presented points to the so called "Classic" model whereas John Gietzen's answer refers to the "Constraint-based" model. Both are right and both do provide the possibility to pass a message for the case of failure.
So let me conclude this:
"Classic" model
"Constraint-based" model
I prefer the latter one since it reads more like a sentence.
这个怎么样:
How about this:
执行完整的正则表达式替换:
应替换为:
并且
Assertion.Assert(\(.*\),\(.*\))
应替换为:
Do a full regex replace:
should be replaced with:
And
Assertion.Assert(\(.*\),\(.*\))
should be replaced with: