public void ThenNextMustUpdateDependentIterators() { var sources = new List<TestSource> { new TestSource{ Count = 0 }, new TestSource{ Count = 100 } }; using (var first = new Iterator(sources.Cast<object>().ToList(), null)) using (var second = new Iterator(new List<object>{first}, null)) { Assert.AreEqual(0, ((IList<object>)first.GetItem())[0]); Assert.AreEqual(100, ((IList<object>)first.GetItem())[1]); Assert.AreEqual(0, ((IList<object>)second.GetItem())[0]); Assert.AreEqual(100, ((IList<object>)second.GetItem())[1]); Iterator.NextAll(Iterator.DefaultScope); Assert.AreEqual(1, ((IList<object>)first.GetItem())[0]); Assert.AreEqual(101, ((IList<object>)first.GetItem())[1]); Assert.AreEqual(1, ((IList<object>)second.GetItem())[0]); Assert.AreEqual(101, ((IList<object>)second.GetItem())[1]); } }
public void ThenGetItemMustNotNext() { var sources = new List<TestSource> { new TestSource{ Count = 0 }, new TestSource{ Count = 100 } }; using (var iterator = new Iterator(sources.Cast<object>().ToList(), null)) { //Incremented on next due to constructor Assert.AreEqual(1, sources[0].Count); Assert.AreEqual(101, sources[1].Count); Assert.AreEqual(0, ((IList<object>)iterator.GetItem())[0]); Assert.AreEqual(100, ((IList<object>)iterator.GetItem())[1]); //Test again to make sure it doesn't pull Assert.AreEqual(0, ((IList<object>)iterator.GetItem())[0]); Assert.AreEqual(100, ((IList<object>)iterator.GetItem())[1]); } }
public void ThenNextMustUpdateFromSources() { var sources = new List<TestSource> { new TestSource{ Count = 0 }, new TestSource{ Count = 100 } }; using (var iterator = new Iterator(sources.Cast<object>().ToList(),null)) { //Incremented on next due to constructor Assert.AreEqual(1, sources[0].Count); Assert.AreEqual(101, sources[1].Count); Assert.AreEqual(0, ((IList<object>)iterator.GetItem())[0] ); Assert.AreEqual(100, ((IList<object>)iterator.GetItem())[1]); Iterator.NextAll(Iterator.DefaultScope); Assert.AreEqual(2, sources[0].Count); Assert.AreEqual(102, sources[1].Count); Assert.AreEqual(1, ((IList<object>)iterator.GetItem())[0]); Assert.AreEqual(101, ((IList<object>)iterator.GetItem())[1]); } }
public void ThenSourcesMustBeFlattened() { var sources = new List<object> { new TestSource{ Count = 0 }, new TestSource{ Count = 100 }, new StringList(new List<object>{"a", "b"}) }; using (var iterator = new Iterator(sources, null)) { var result = ((IList<object>) iterator.GetItem()); Assert.AreEqual(0, result[0]); Assert.AreEqual(100, result[1]); Assert.AreEqual("a", result[2]); Assert.AreEqual("b", result[3]); } }
public void ThenSequentialIteratorSourcesMustBeFlattened() { var sources = new List<object> { new TestSource{ Count = 0 }, new TestSource{ Count = 100 }, new StringList(new List<object>{"a", "b"}) }; using (var first = new Iterator(sources, null)) using (var second = new Iterator(new List<object> { first, sources[2] }, null)) { var result = ((IList<object>)second.GetItem()); Assert.AreEqual(0, result[0]); Assert.AreEqual(100, result[1]); Assert.AreEqual("a", result[2]); Assert.AreEqual("b", result[3]); Assert.AreEqual("a", result[4]); Assert.AreEqual("b", result[5]); } }