public async Task DisposeAfterPartialEnumeration()
        {
            // ARRANGE

            var testDisposable = new TestDisposable();
            var enumerator     = new AsyncEnumerator <int>(async yield =>
            {
                using (testDisposable)
                {
                    await yield.ReturnAsync(1);
                    await yield.ReturnAsync(2);
                    await yield.ReturnAsync(3);
                }
            });

            // ACT

            await enumerator.MoveNextAsync();

            enumerator.Dispose();

            // ASSERT

            Assert.IsTrue(testDisposable.HasDisposed);
        }
        public void OnDisposeActionIsCalled()
        {
            // ARRANGE

            var testDisposable = new TestDisposable();

            var enumerator = new AsyncEnumerator <int>(async yield =>
            {
                await yield.ReturnAsync(1);
            },
                                                       onDispose: () => testDisposable.Dispose());

            // ACT

            enumerator.Dispose();

            // ASSERT

            Assert.IsTrue(testDisposable.HasDisposed);
        }
        public async Task EnumerationMustEndAfterDispose()
        {
            // ARRANGE

            var enumerator = new AsyncEnumerator <int>(async yield =>
            {
                await yield.ReturnAsync(1);
                await yield.ReturnAsync(2);
            });

            await enumerator.MoveNextAsync();

            // ACT

            enumerator.Dispose();
            bool moveNextResult = await enumerator.MoveNextAsync();

            int currentElement = enumerator.Current;

            // ASSERT

            Assert.IsFalse(moveNextResult, "MoveNextAsync must return False after Dispose");
            Assert.AreEqual(1, currentElement, "Current must not change after Dispose");
        }