예제 #1
0
        public void TestStoppingVisitor()
        {
            EqualityFindingVisitor <KeyValuePair <string, string> > visitor = new EqualityFindingVisitor <KeyValuePair <string, string> >(new KeyValuePair <string, string>("b", "bb"), new KeyValuePairEqualityComparer <string, string>());

            VisitableHashtable <string, string> h = GetTestHashtable();

            h.Accept(visitor);

            Assert.AreEqual(visitor.HasCompleted, true);
            Assert.AreEqual(visitor.Found, true);

            visitor = new EqualityFindingVisitor <KeyValuePair <string, string> >
                      (
                new KeyValuePair <string, string>("d", "dd"),
                new KeyValuePairEqualityComparer <string, string>()
                      );
            h.Accept(visitor);

            Assert.AreEqual(visitor.HasCompleted, false);
            Assert.AreEqual(visitor.Found, false);
        }
예제 #2
0
        public void TestVisitor()
        {
            TrackingVisitor <KeyValuePair <string, string> > visitor = new TrackingVisitor <KeyValuePair <string, string> >();

            VisitableHashtable <string, string> h = GetTestHashtable();

            h.Accept(visitor);

            Assert.AreEqual(visitor.TrackingList.Count, 3);

            bool found = false;

            for (int i = 0; i < visitor.TrackingList.Count; i++)
            {
                if ((visitor.TrackingList[i].Key == "a") && (visitor.TrackingList[i].Value == "aa"))
                {
                    found = true;
                    break;
                }
            }

            Assert.AreEqual(found, true);

            found = false;
            for (int i = 0; i < visitor.TrackingList.Count; i++)
            {
                if ((visitor.TrackingList[i].Key == "b") && (visitor.TrackingList[i].Value == "bb"))
                {
                    found = true;
                    break;
                }
            }

            Assert.AreEqual(found, true);

            found = false;
            for (int i = 0; i < visitor.TrackingList.Count; i++)
            {
                if ((visitor.TrackingList[i].Key == "c") && (visitor.TrackingList[i].Value == "cc"))
                {
                    found = true;
                    break;
                }
            }

            Assert.AreEqual(found, true);
        }
예제 #3
0
        public void TestNullVisitor()
        {
            VisitableHashtable <string, string> h = new VisitableHashtable <string, string>();

            h.Accept(null);
        }