【发布时间】:2020-03-16 22:03:50
【问题描述】:
我想使用 fluent-assertions 测试返回集合的方法,以确保返回的集合是其他集合的子集合,我尝试了 fatherCollection.Should().Contain(childCollection); 但不起作用。该怎么做?
【问题讨论】:
-
你能提供一个示例数据吗?这将是一个很大的帮助。
标签: c# unit-testing fluent-assertions
我想使用 fluent-assertions 测试返回集合的方法,以确保返回的集合是其他集合的子集合,我尝试了 fatherCollection.Should().Contain(childCollection); 但不起作用。该怎么做?
【问题讨论】:
标签: c# unit-testing fluent-assertions
您可以在子集合中的每个项目上使用collection.Should().ContainEquivalentOf(item)。
【讨论】:
AssertionScope 包裹它,失败的消息将包括所有失败的项目,而不仅仅是第一个。