public void EnumeratorOnlyReturnsItemsOfCorrectType() { var items = new object[] { 1, "string" }; using (var comCleanupEnumerator = new ComCleanupEnumerator <string>(items.GetEnumerator(), o => {})) { comCleanupEnumerator.MoveNext(); Assert.Equal("string", comCleanupEnumerator.Current); Assert.Equal(false, comCleanupEnumerator.MoveNext()); } }
public void EnumeratorOnlyReturnsItemsOfCorrectType() { var items = new object[] { 1, "string" }; using (var comCleanupEnumerator = new ComCleanupEnumerator<string>(items.GetEnumerator(), o => {})) { comCleanupEnumerator.MoveNext(); Assert.Equal("string", comCleanupEnumerator.Current); Assert.Equal(false, comCleanupEnumerator.MoveNext()); } }
public void EnumeratorCallsCleanupIfDisposeCalledBeforeMoveNextReturnsFalse() { var cleanupCalled = false; var enumerable = new[] { "string" }; using (var comCleanupEnumerator = new ComCleanupEnumerator <string>(enumerable.GetEnumerator(), o => cleanupCalled = true)) { //MoveNext will return true, leaving the current value not cleaned up yet. comCleanupEnumerator.MoveNext(); } Assert.True(cleanupCalled); }
public void EnumeratorCallsCleanupIfDisposeCalledBeforeMoveNextReturnsFalse() { var cleanupCalled = false; var enumerable = new[] { "string" }; using (var comCleanupEnumerator = new ComCleanupEnumerator<string>(enumerable.GetEnumerator(), o => cleanupCalled = true)) { //MoveNext will return true, leaving the current value not cleaned up yet. comCleanupEnumerator.MoveNext(); } Assert.True(cleanupCalled); }
public void EnumeratorCallsCleanupOnSingleElement() { var cleanupCalled = false; var enumerable = new[] { "string" }; using (var comCleanupEnumerator = new ComCleanupEnumerator <string>(enumerable.GetEnumerator(), o => cleanupCalled = true)) { //Move to first item, then move next will return false because no more elements comCleanupEnumerator.MoveNext(); comCleanupEnumerator.MoveNext(); } Assert.True(cleanupCalled); }
public void EnumeratorCallsCleanupOnSingleElement() { var cleanupCalled = false; var enumerable = new[] { "string" }; using (var comCleanupEnumerator = new ComCleanupEnumerator<string>(enumerable.GetEnumerator(), o => cleanupCalled = true)) { //Move to first item, then move next will return false because no more elements comCleanupEnumerator.MoveNext(); comCleanupEnumerator.MoveNext(); } Assert.True(cleanupCalled); }