I was confused when working with a dictionary that HaveSameCount didn't seem to be resolving properly. I would expect that GenericDictionaryAssertions would derive from GenericCollectionAssertions to provide the same methods.
It looks like most of these methods are just explicitly implemented on DictionaryAssertions, would it be reasonable to add a few more, or is there a reason that these methods aren't included?
would it be reasonable to add a few more, or is there a reason that these methods aren't included?
Absolutely. It's just that nobody asked for anything more yet.
A reason GenericDictionaryAssertions does not derive from GenericCollectionAssertions is because some assertions on IEnumerable<T> are not very useful on Dictionary<TKey, TValue>.
E.g. BeInAscendingOrder and Start/EndWith which assumes and ordering of the elements.
HaveSameCount makes fine sense for dictionaries.
Until this is implemented a workaround is to use
c#
subject.AsEnumerable().Should().HaveSameCount(expected);
would it be reasonable to add a few more
Do you have others in mind, that you feel are missing?
Nope, not specifically. Just wanted to ask the question in case there was some previous discussion that I wasn't able to find before opening a PR or something.
Most helpful comment
Nope, not specifically. Just wanted to ask the question in case there was some previous discussion that I wasn't able to find before opening a PR or something.