public void WhenGetEnumerator_ReturnsResults() { var source = new[] { new object(), new object(), new object() }; var next = new Mock <IChainedEnumerator <object> >(); var wrapper = new ChainedEnumeratorWrapper <object>(source, next.Object); wrapper.ToArray().ShouldBe(source); }
public void WhenEnumerating_CurrentMatchesSource() { var source = new object[] { 1, 2, 3, 4 }.AsEnumerable().GetEnumerator(); var next = new Mock <IChainedEnumerator <object> >(); var wrapper = new ChainedEnumeratorWrapper <object>(source, next.Object); wrapper.MoveNext(); source.Current.ShouldBe(wrapper.Current); }
public void WhenEnumerating_ShouldReturnTrueUntilNoMoreItems() { var source = new object[] { 1, 2, 3 }; var next = new Mock <IChainedEnumerator <object> >(); var wrapper = new ChainedEnumeratorWrapper <object>(source, next.Object); wrapper.MoveNext().ShouldBeTrue(); wrapper.MoveNext().ShouldBeTrue(); wrapper.MoveNext().ShouldBeTrue(); wrapper.MoveNext().ShouldBeFalse(); }
public void WhenEnumerating_NoMoreItemsShouldMarkNextAsFinished() { var source = new object[] { 1, 2, 3 }; var next = new Mock <IChainedEnumerator <object> >(); next.Setup(x => x.AddItem(It.IsAny <object>())); next.Setup(x => x.MarkAsFinished()); var wrapper = new ChainedEnumeratorWrapper <object>(source, next.Object); wrapper.MoveNext(); wrapper.MoveNext(); wrapper.MoveNext(); wrapper.MoveNext(); next.Verify(x => x.AddItem(It.IsAny <object>()), Times.Exactly(3)); next.Verify(x => x.MarkAsFinished(), Times.Once); }
public void WhenEnumerating_ResetShouldResetNext() { var source = new Mock <IEnumerator <object> >(); source.Setup(x => x.MoveNext()).Returns(true); source.Setup(x => x.Reset()); var next = new Mock <IChainedEnumerator <object> >(); next.Setup(x => x.AddItem(It.IsAny <object>())); next.Setup(x => x.Reset()); var wrapper = new ChainedEnumeratorWrapper <object>(source.Object, next.Object); wrapper.MoveNext(); wrapper.MoveNext(); wrapper.MoveNext(); wrapper.Reset(); next.Verify(x => x.AddItem(It.IsAny <object>()), Times.Exactly(3)); next.Verify(x => x.Reset(), Times.Once); }