【问题标题】:How to assert a collection is a child of other collection using fluent-assertions?如何使用流利断言断言一个集合是其他集合的子集合?
【发布时间】:2020-03-16 22:03:50
【问题描述】:

我想使用 fluent-assertions 测试返回集合的方法,以确保返回的集合是其他集合的子集合,我尝试了 fatherCollection.Should().Contain(childCollection); 但不起作用。该怎么做?

【问题讨论】:

  • 你能提供一个示例数据吗?这将是一个很大的帮助。

标签: c# unit-testing fluent-assertions


【解决方案1】:

您可以在子集合中的每个项目上使用collection.Should().ContainEquivalentOf(item)。

【讨论】:

  • 用AssertionScope 包裹它,失败的消息将包括所有失败的项目,而不仅仅是第一个。
猜你喜欢
  • 2012-02-18
  • 2016-10-19
  • 2013-09-24
  • 2021-11-21
  • 2022-03-23
  • 2013-06-07
  • 2020-11-21
  • 2020-02-18
  • 1970-01-01
相关资源
最近更新 更多