public void ReduceLeftDisposesOfTheEnumerator() { var source = new[] { 1, 2, 3 }; var enumerableSpy = new EnumerableSpy <int>(source); enumerableSpy.ReduceLeft <int, int>((_, __) => _); Assert.That(enumerableSpy.NumCallsToDispose, Is.EqualTo(1)); }
public void IsEmptyDisposesOfTheEnumerator() { var source = new[] { 1, 2, 3 }; var enumerableSpy = new EnumerableSpy <int>(source); enumerableSpy.IsEmpty(); Assert.That(enumerableSpy.NumCallsToDispose, Is.EqualTo(1)); }
public void PatchDisposesOfTheEnumerator() { var source = Utils.EmptySequence <int>(); var patch = Utils.EmptySequence <int>(); var enumerableSpy = new EnumerableSpy <int>(source); enumerableSpy.Patch(0, patch, 0).ToList(); Assert.That(enumerableSpy.NumCallsToDispose, Is.EqualTo(1)); }
public void MapYields() { var enumerableSpy = new EnumerableSpy <int>(new[] { 1, 2, 3 }); var actual = enumerableSpy.Map(i => i * i); Assert.That(enumerableSpy.NumCallsToMoveNext, Is.EqualTo(0)); Assert.That(actual.ElementAt(1), Is.EqualTo(4)); Assert.That(enumerableSpy.NumCallsToMoveNext, Is.EqualTo(2)); }
public EnumeratorSpy(EnumerableSpy <T> enumerableSpy) { _enumerableSpy = enumerableSpy; }