Assert.That 和传统语法之间有功能差异吗?
在 NUnit 中,我可以编写 或
Assert.That(5, Is.EqualTo(5));
这
Assert.AreEqual(5, 5);
两种形式之间有任何功能差异吗?还是两者之间的选择只是取决于个人喜好和可读性?
In NUnit, I can write either
Assert.That(5, Is.EqualTo(5));
or
Assert.AreEqual(5, 5);
Is there any functional difference between these two forms or is the choice between the two just down to personal preference and perception of readability?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您给出的示例之间没有任何语义差异。这完全取决于偏好。
There isn't any semantic difference between the examples that you give. It solely comes down to preference.
唯一的区别是可读性以及您对此的偏好。值得注意的是,旧的语法已被重新实现,以在幕后工作新的语法,因此功能上是相同的。
The only difference is readability, and your preference on that matter. It is worth noting that the older syntax has been reimplemented to work off of the new behind the scenes, so that are functionally the same.
不,没有功能差异。这只是流畅的 API 与经典语法的对比。这确实取决于个人喜好。
No, there is no functional difference. This is just the fluent API versus the classical syntax. It does come down to personal preference.