MoreLINQ icon indicating copy to clipboard operation
MoreLINQ copied to clipboard

Backsert tests don't cover enumerator disposal

Open atifaziz opened this issue 6 years ago • 2 comments

If the using is removed from the following line in Backsert:

https://github.com/morelinq/MoreLINQ/blob/ce57548c166c9ad59c9c5f6712bbc42bb358ca50/MoreLinq/Backsert.cs#L70

then its tests, like the following that uses TestingSequence:

https://github.com/morelinq/MoreLINQ/blob/ce57548c166c9ad59c9c5f6712bbc42bb358ca50/MoreLinq.Test/BacksertTest.cs#L56-L63

don't break!

This is because Backsert internally uses other operators like Concat and CountDown and so provide a false positive because while Backsert is modified to not dispose anymore, Concat and CountDown do! This highlights a flaw that relying on TestingSequence is weak and won't cover what it's designed to test if an implementation is refactored internally to rely on other operations. TestingSequence is only as good as the implementation fully stand on its own.

This came up while reviewing issue #649. Thanks @Orace!

atifaziz avatar Nov 06 '19 08:11 atifaziz

A solution is to build hand crafted implementation for every methods and prohibit nested enumerable ;)

Orace avatar Nov 07 '19 21:11 Orace

A solution is to build hand crafted implementation for every methods and prohibit nested enumerable ;)

Or hijack MoreEnumerable extension methods within the test project as is done for Enumerable and inject TestingSequence. 💭

atifaziz avatar Nov 26 '19 18:11 atifaziz