2

I'm just getting started with Fluent Assertions 4.1.1. Looks like the code for comparing dictionaries is

 actualDictionary.ShouldAllBeEquivalentTo(expectedDictionary);

but how do I specify my own equality function (comparer) for the keys and values if I don't want to use their Equals() implementation?

For collections it seems to be:

actualCollection.Should().Equal(expectedCollection, MyComparisonFunc);

I'm looking for the IDictionary<K,V> and IReadOnlyDictionary<K,V> equivalents of that.

Edit: same question for Contain() on a collection.

EM0
  • 5,369
  • 7
  • 51
  • 85

1 Answers1

1

There's are overloads of Should().Contain() and Should().Equal() for collections that take a predicate, but unfortunately, none exists for dictionaries. However, the equivalency rules are highly extendible. Checkout the unit tests to see some examples

Dennis Doomen
  • 8,368
  • 1
  • 32
  • 44