public void CreateValueNextTest() { NestedListNode <int> node1 = ChurchNestedList <int> .Create(1)(ChurchNestedList <int> .Null); NestedListNode <int> node2 = ChurchNestedList <int> .Create(2)(node1); NestedListNode <int> node3 = ChurchNestedList <int> .Create(3)(node2); Assert.AreEqual(1, node1.Value()); Assert.AreEqual(ChurchNestedList <int> .Null, node1.Next()); Assert.AreEqual(2, node2.Value()); Assert.AreEqual(node1, node2.Next()); Assert.AreEqual(3, node3.Value()); Assert.AreEqual(node2, node3.Next()); Assert.AreEqual(node2.Value(), node3.Next().Value()); Assert.AreEqual(node1.Value(), node3.Next().Next().Value()); Assert.AreEqual(ChurchNestedList <int> .Null, node3.Next().Next().Next()); try { ChurchNestedList <int> .Null.Next(); Assert.Fail(); } catch (InvalidCastException exception) { Trace.WriteLine(exception); } }
public void IsNullTest() { NestedListNode <int> node1 = ChurchNestedList <int> .Create(1)(ChurchNestedList <int> .Null); NestedListNode <int> node2 = ChurchNestedList <int> .Create(2)(node1); NestedListNode <int> node3 = ChurchNestedList <int> .Create(3)(node2); Assert.IsTrue(ChurchNestedList <object> .Null.IsNull().Unchurch()); Assert.IsFalse(node1.IsNull().Unchurch()); Assert.IsFalse(node2.IsNull().Unchurch()); Assert.IsFalse(node3.IsNull().Unchurch()); Assert.IsTrue(node1.Next().IsNull().Unchurch()); Assert.IsFalse(node2.Next().IsNull().Unchurch()); Assert.IsFalse(node3.Next().IsNull().Unchurch()); }