public void AsEnumerable() { DataProducer <string> subject = new DataProducer <string>(); IEnumerable <string> result = subject.AsEnumerable(); subject.ProduceAndEnd("a", "b", "c", "d"); Assert.IsTrue(result.SequenceEqual(new[] { "a", "b", "c", "d" })); }
public void AsEnumerableWithModificationsInPlace() { DataProducer <int> subject = new DataProducer <int>(); IEnumerable <int> result = subject.AsEnumerable(); Assert.IsTrue(result.SequenceEqual(new int[0])); subject.Produce(10); Assert.IsTrue(result.SequenceEqual(new[] { 10 })); subject.Produce(20); Assert.IsTrue(result.SequenceEqual(new[] { 10, 20 })); subject.End(); Assert.IsTrue(result.SequenceEqual(new[] { 10, 20 })); }