我刚刚开始使用Fluent断言4.1.1。看起来比较字典的代码是
actualDictionary.ShouldAllBeEquivalentTo(expectedDictionary);
但如果我不想使用他们的Equals()实现,如何为键和值指定我自己的相等函数(comparer)?
对于收藏品,似乎是:
actualCollection.Should().Equal(expectedCollection, MyComparisonFunc);
我正在寻找IDictionary<K,V>
和IReadOnlyDictionary<K,V>
等价物。
编辑:集合中包含()的相同问题。
答案 0 :(得分:1)
对于带有谓词的集合,$rsp
和Should().Contain()
都有重载,但遗憾的是,字典中不存在。但是,等效规则是高度可扩展的。查看unit tests以查看一些示例