public void Works_with_simple_value()
 {
     var items = new[] { 1 };
     var invocations = items.AsFunctionsTree();
     var e = invocations.GetEnumerator();
     var sut = new TextInvocationReader();
     IsTrue(e.MoveNext());
     e.Current.Accept(sut);
     AreEqual("1", sut.ToString());
     IsFalse(e.MoveNext());
 }
 public void Works_with_parameterless_delegate()
 {
     var func = new Func<string>(() => "a");
     var items = new[] { func };
     var invocations = items.AsFunctionsTree();
     var e = invocations.GetEnumerator();
     var sut = new TextInvocationReader();
     IsTrue(e.MoveNext());
     e.Current.Accept(sut);
     AreEqual("foo()", sut.ToString());
     IsFalse(e.MoveNext());
 }
 public void Works_with_call_stack()
 {
     var func = new Func<string, string>(x => "a" + x);
     var items = new object[] { func, "b" };
     var invocations = items.AsFunctionsTree(1);
     var e = invocations.GetEnumerator();
     var sut = new TextInvocationReader();
     IsTrue(e.MoveNext());
     sut.Clear();
     e.Current.Accept(sut);
     AreEqual("foo(foo(\"b\"))", sut.ToString());
     IsTrue(e.MoveNext());
     sut.Clear();
     e.Current.Accept(sut);
     AreEqual("foo(\"b\")", sut.ToString());
     IsTrue(e.MoveNext());
     sut.Clear();
     e.Current.Accept(sut);
     AreEqual("\"b\"", sut.ToString());
     IsFalse(e.MoveNext());
 }
 public void Works_with_delegate()
 {
     var func = new Func<int, string>(x => "a" + x);
     var items = new object[] { 1, func, 2 };
     var invocations = items.AsFunctionsTree();
     var e = invocations.GetEnumerator();
     var sut = new TextInvocationReader();
     IsTrue(e.MoveNext());
     e.Current.Accept(sut);
     AreEqual("1", sut.ToString());
     IsTrue(e.MoveNext());
     sut.Clear();
     e.Current.Accept(sut);
     AreEqual("foo(1)", sut.ToString());
     IsTrue(e.MoveNext());
     sut.Clear();
     e.Current.Accept(sut);
     AreEqual("foo(2)", sut.ToString());
     IsTrue(e.MoveNext());
     sut.Clear();
     e.Current.Accept(sut);
     AreEqual("2", sut.ToString());
     IsFalse(e.MoveNext());
 }