【问题标题】:How to throw exceptions using fluentassertions in foreach loop in C# [closed]如何在 C# 的 foreach 循环中使用 fluentassertions 引发异常 [关闭]
【发布时间】:2015-07-31 09:03:03
【问题描述】:

我正在为字典运行 foreach 循环,并使用 ShouldThrow 在测试失败时抛出异常。

但循环在第一次失败时退出。有没有办法推迟实际违规并将它们作为单个异常抛出?

【问题讨论】:

  • 你能分享你的foreach循环的代码吗?
  • .... 简单地删除您的整个问题并不是正确的方法。怎么回事?

标签: c# fluent-assertions


【解决方案1】:

您可以将多个对 FluentAssertions 断言方法的调用封装在 using new AssertionScope()) 中。这将导致它收集所有违规行为并将它们扔到 using 块的末尾。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多