public void Works_when_add_argument_during_iteration() { var function = new Func<string, string, string>((x, y) => x + y); var sut = new Basic.Appendable(function, "a", "b"); var e = sut.GetEnumerator(); IsTrue(e.MoveNext()); AreEqual("aa", e.Current.Function.DynamicInvoke()); sut.Add("c"); IsTrue(e.MoveNext()); AreEqual("ab", e.Current.Function.DynamicInvoke()); IsTrue(e.MoveNext()); AreEqual("ba", e.Current.Function.DynamicInvoke()); sut.Add("d"); IsTrue(e.MoveNext()); AreEqual("bb", e.Current.Function.DynamicInvoke()); IsFalse(e.MoveNext()); }
public void Works_with_two_consecutive_iterations() { var function = new Func<string, string, string>((x, y) => x + y); var sut = new Basic.Appendable(function, "a", "b"); var e = sut.GetEnumerator(); IsTrue(e.MoveNext()); AreEqual("aa", e.Current.Function.DynamicInvoke()); IsTrue(e.MoveNext()); AreEqual("ab", e.Current.Function.DynamicInvoke()); IsTrue(e.MoveNext()); AreEqual("ba", e.Current.Function.DynamicInvoke()); IsTrue(e.MoveNext()); AreEqual("bb", e.Current.Function.DynamicInvoke()); IsFalse(e.MoveNext()); e = sut.GetEnumerator(); sut.Add("c"); IsTrue(e.MoveNext()); AreEqual("aa", e.Current.Function.DynamicInvoke()); IsTrue(e.MoveNext()); AreEqual("ab", e.Current.Function.DynamicInvoke()); IsTrue(e.MoveNext()); AreEqual("ba", e.Current.Function.DynamicInvoke()); IsTrue(e.MoveNext()); AreEqual("bb", e.Current.Function.DynamicInvoke()); IsTrue(e.MoveNext()); AreEqual("ca", e.Current.Function.DynamicInvoke()); IsTrue(e.MoveNext()); AreEqual("cb", e.Current.Function.DynamicInvoke()); IsTrue(e.MoveNext()); AreEqual("ac", e.Current.Function.DynamicInvoke()); IsTrue(e.MoveNext()); AreEqual("bc", e.Current.Function.DynamicInvoke()); IsTrue(e.MoveNext()); AreEqual("cc", e.Current.Function.DynamicInvoke()); IsFalse(e.MoveNext()); }