public void TestLinks()
        {
            LListNode <string> empty  = new LListNode <string>();
            LListNode <string> valueA = new LListNode <string>("A");
            LListNode <string> valueB = new LListNode <string>("B");

            LListNode <string> .LList list = new LListNode <string> .LList();

            list.AddFirst(empty);
            Assert.AreEqual(1, list.Count);
            Assert.AreEqual(empty, list.First);
            Assert.AreEqual(empty, list.Last);
            Assert.IsNull(empty.Next);
            Assert.IsNull(empty.Previous);

            list.AddLast(valueB);
            Assert.AreEqual(2, list.Count);
            Assert.AreEqual(empty, list.First);
            Assert.AreEqual(valueB, list.Last);

            Assert.AreEqual(valueB, empty.Next);
            Assert.IsNull(empty.Previous);

            Assert.AreEqual(empty, valueB.Previous);
            Assert.IsNull(valueB.Next);

            list.AddFirst(valueA);
            Assert.AreEqual(3, list.Count);
            Assert.AreEqual(valueA, list.First);
            Assert.AreEqual(valueB, list.Last);

            Assert.AreEqual(valueB, empty.Next);
            Assert.AreEqual(valueA, empty.Previous);

            Assert.AreEqual(empty, valueA.Next);
            Assert.IsNull(valueA.Previous);

            Assert.AreEqual(empty, valueB.Previous);
            Assert.IsNull(valueB.Next);

            list.Remove(empty);
            Assert.AreEqual(2, list.Count);
            Assert.AreEqual(valueA, list.First);
            Assert.AreEqual(valueB, list.Last);

            Assert.AreEqual(valueB, valueA.Next);
            Assert.IsNull(valueA.Previous);

            Assert.AreEqual(valueA, valueB.Previous);
            Assert.IsNull(valueB.Next);
        }
        public void TestEnumerator()
        {
            LListNode <string> .LList list = new LListNode <string> .LList();

            list.AddLast("B");
            list.AddFirst("A");
            System.Collections.Generic.IEnumerator <LListNode <string> > e = list.GetEnumerator();
            using (e)
            {
                Assert.IsTrue(e.MoveNext());
                Assert.IsTrue(ReferenceEquals(e.Current, ((System.Collections.IEnumerator)e).Current));
                Assert.AreEqual("A", e.Current.Value);
                list.Remove(e.Current);

                Assert.IsTrue(e.MoveNext());
                Assert.IsTrue(ReferenceEquals(e.Current, ((System.Collections.IEnumerator)e).Current));
                Assert.AreEqual("B", e.Current.Value);
                list.Remove(e.Current);

                Assert.IsFalse(e.MoveNext());

                Assert.IsTrue(list.IsEmpty);
                list.AddLast(String.Empty);

                e.Reset();
                Assert.IsTrue(e.MoveNext());
                Assert.AreEqual(String.Empty, e.Current.Value);
                Assert.IsFalse(e.MoveNext());

                try
                {
                    GC.KeepAlive(e.Current);
                    Assert.Fail();
                }
                catch (InvalidOperationException)
                { }
            }

            //now e is disposed...
            try
            {
                e.MoveNext();
                Assert.Fail();
            }
            catch (ObjectDisposedException) { }
            try
            {
                GC.KeepAlive(e.Current);
                Assert.Fail();
            }
            catch (ObjectDisposedException) { }
            try
            {
                e.Reset();
                Assert.Fail();
            }
            catch (ObjectDisposedException) { }
        }
        public void TestAddFirst()
        {
            LListNode <string> .LList list = new LListNode <string> .LList();

            Assert.IsTrue(list.IsEmpty);
            list.AddLast("B");
            Assert.IsFalse(list.IsEmpty);
            list.AddFirst("A");
            Assert.AreEqual("A", list.First.Value);
            Assert.AreEqual("B", list.Last.Value);
        }