public void GetCurrent__When_SourceIsEmpty_Must_ThrowAnException() { target = new WritingEnumerator <string>(new List <string>()); Assert.Throws <ArgumentOutOfRangeException>( () => { var current = target.Current; }); }
public void IteratingOverItems__When_SourceIsNotEmpty_ShouldReturnAllItemsInTheSource(IList <string> values) { target = new WritingEnumerator <string>(values); foreach (var value in values) { target.MoveNext(); Assert.AreEqual(value, target.Current); } }
public void Current__When_SourceIsEmptyInitially_WhenAnItemIsAdded_TheItemMustBeTheCurrentItem( IList <string> values) { target = new WritingEnumerator <string>(new List <string>()); foreach (var value in values) { target.Add(value); Assert.AreEqual(value, target.Current); } }
public void AddingItems__When_SourceIsEmptyInitially__Must_AddItemAtTheEndOfCollection(IList <string> values) { var source = new List <string>(); target = new WritingEnumerator <string>(source); foreach (var value in values) { target.Add(value); } AssertionExtensions.SequencesAreEqual(values, source); }
public void AddingItems__When_SourceIsNotEmptyInitially__Must_AddItemAtTheEndOfCollection( IList <string> source, IList <string> values) { var expectedCollection = source.Concat(values).ToList(); target = new WritingEnumerator <string>(source); foreach (var value in values) { target.Add(value); } AssertionExtensions.SequencesAreEqual(expectedCollection, source); }
public void FullEnumeration__When_SourceIsEmptyInitially_When_ItemsAreAdded__AndPositionIsReset__MustReturnEveryItem_InTheOriginalSequence( IList <string> values) { var source = new List <string>(); target = new WritingEnumerator <string>(source); foreach (var value in values) { target.Add(value); } target.ResetPosition(); foreach (var value in values) { target.MoveNext(); Assert.AreEqual(value, target.Current); } }
public Smartnumerator(IEnumerator <TValue> source) { this.source = source; this.copyManager = new WritingEnumerator <TValue>(new List <TValue>()); }