コード例 #1
0
        public void TestStoppingVisitor()
        {
            VisitableLinkedList <int> l = GetTestCustomLinkedList();

            ComparableFindingVisitor <int> visitor = new ComparableFindingVisitor <int>(6);

            l.Accept(visitor);

            Assert.AreEqual(visitor.Found, true);

            visitor = new ComparableFindingVisitor <int>(99);
            l.Accept(visitor);
            Assert.AreEqual(visitor.Found, false);
        }
コード例 #2
0
        public void TestVisitor()
        {
            VisitableLinkedList <int> l = GetTestCustomLinkedList();
            SumVisitor visitor          = new SumVisitor();

            l.Accept(visitor);

            Assert.AreEqual(visitor.Sum, 0 + 3 + 6 + 9 + 12);
        }
コード例 #3
0
        public void TestNullVisitor()
        {
            VisitableLinkedList <int> l = new VisitableLinkedList <int>();

            l.Accept(null);
        }