tpierrain / NFluent

Smooth your .NET TDD experience with NFluent! NFluent is an ergonomic assertion library which aims to fluent your .NET TDD experience (based on simple Check.That() assertion statements). NFluent aims your tests to be fluent to write (with a super-duper-happy 'dot' auto-completion experience), fluent to read (i.e. as close as possible to plain English expression), but also fluent to troubleshoot, in a less-error-prone way comparing to the classical .NET test frameworks. NFluent is also directly inspired by the awesome Java FEST Fluent assertion/reflection library (http://fest.easytesting.org/)
Apache License 2.0
310 stars 53 forks source link

fix: DifferenceFinders against empty collection #345

Closed eugbaranov closed 1 week ago

eugbaranov commented 2 weeks ago

Currently e.g.:

Check.That(Enumerable.Repeat(1, 2)).IsEquivalentTo(Enumerable.Repeat(0, 0))

Would blow up with:

System.ArgumentException : An item with the same key has already been added. Key: 1
Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
Dictionary`2.Add(TKey key, TValue value)
DifferenceFinders.ScanEnumeration(IEnumerable actualEnumerable, IEnumerable expectedEnumerable, String firstName, Func`2 namingCallback, Int64 sutIndex, Int64 expectedIndex, IDictionary`2 firstSeen, Option options)
dupdob commented 2 weeks ago

Hello thanks for reporting this and opening this issue and this PR. Could you please add a unit test for this scenario ?

Note: the actual issue is that the exception is raised if the actual enumeration is missing two entries or more

eugbaranov commented 2 weeks ago

Hi, I've added a related test.

dupdob commented 1 week ago

Thanks I will make a release in the coming days