public void GetEnumerator_should_throw_when_called_more_than_once()
        {
            var mockCursor = new Mock <IAsyncCursor <BsonDocument> >();
            var subject    = new AsyncCursorEnumerableOneTimeAdapter <BsonDocument>(mockCursor.Object, CancellationToken.None);

            subject.GetEnumerator();

            Action action = () => subject.GetEnumerator();

            action.ShouldThrow <InvalidOperationException>();
        }
        public void GetEnumerator_should_return_expected_result()
        {
            var mockCursor = new Mock <IAsyncCursor <BsonDocument> >();

            mockCursor.SetupSequence(c => c.MoveNext(CancellationToken.None)).Returns(true).Returns(false);
            mockCursor.Setup(c => c.Current).Returns(new[] { new BsonDocument("_id", 0) });
            var subject = new AsyncCursorEnumerableOneTimeAdapter <BsonDocument>(mockCursor.Object, CancellationToken.None);

            var result = subject.GetEnumerator();

            result.MoveNext().Should().BeTrue();
            result.Current.Should().Be(new BsonDocument("_id", 0));
            result.MoveNext().Should().BeFalse();
        }
        public void GetEnumerator_should_return_expected_result()
        {
            var cursor = Substitute.For <IAsyncCursor <BsonDocument> >();

            cursor.MoveNext().Returns(true, false);
            cursor.Current.Returns(new[] { new BsonDocument("_id", 0) });
            var subject = new AsyncCursorEnumerableOneTimeAdapter <BsonDocument>(cursor, CancellationToken.None);

            var result = subject.GetEnumerator();

            result.MoveNext().Should().BeTrue();
            result.Current.Should().Be(new BsonDocument("_id", 0));
            result.MoveNext().Should().BeFalse();
        }