Ejemplo n.º 1
0
        public void CompletedVisitor2()
        {
            var bag = new Bag<string> { "5", "4", "3", "2" };

            var visitor = new CompletedTrackingVisitor<string>();
            bag.AcceptVisitor<string>(visitor);
        }
Ejemplo n.º 2
0
        public void CompletedVisitor1()
        {
            var bag = new Bag<string> { "5", "4", "3", "2" };

            var visitor = new CompletedTrackingVisitor<KeyValuePair<string, int>>();
            bag.AcceptVisitor<KeyValuePair<string, int>>(visitor);
        }
Ejemplo n.º 3
0
        public void CompletedVisitor2()
        {
            var bag = new Bag <string> {
                "5", "4", "3", "2"
            };

            var visitor = new CompletedTrackingVisitor <string>();

            bag.AcceptVisitor <string>(visitor);
        }
Ejemplo n.º 4
0
        public void CompletedVisitor1()
        {
            var bag = new Bag <string> {
                "5", "4", "3", "2"
            };

            var visitor = new CompletedTrackingVisitor <KeyValuePair <string, int> >();

            bag.AcceptVisitor <KeyValuePair <string, int> >(visitor);
        }
Ejemplo n.º 5
0
        public void Simple2()
        {
            var bag = new Bag<string> { "5", "4", "3", "2" };

            var visitor = new TrackingVisitor<KeyValuePair<string, int>>();
            bag.AcceptVisitor<KeyValuePair<string, int>>(visitor);

            Assert.AreEqual(visitor.TrackingList.Count, 4);
            Assert.IsTrue(visitor.TrackingList.Contains(new KeyValuePair<string, int>("5", 1)));
            Assert.IsTrue(visitor.TrackingList.Contains(new KeyValuePair<string, int>("4", 1)));
            Assert.IsTrue(visitor.TrackingList.Contains(new KeyValuePair<string, int>("3", 1)));
            Assert.IsTrue(visitor.TrackingList.Contains(new KeyValuePair<string, int>("2", 1)));
        }
Ejemplo n.º 6
0
        public void Simple()
        {
            var bag = new Bag<string> { "5", "4", "3", "2" };

            var visitor = new TrackingVisitor<string>();
            bag.AcceptVisitor<string>(visitor);

            Assert.AreEqual(visitor.TrackingList.Count, 4);
            Assert.IsTrue(visitor.TrackingList.Contains("5"));
            Assert.IsTrue(visitor.TrackingList.Contains("4"));
            Assert.IsTrue(visitor.TrackingList.Contains("3"));
            Assert.IsTrue(visitor.TrackingList.Contains("2"));
        }
Ejemplo n.º 7
0
        public void Simple2()
        {
            var bag = new Bag <string> {
                "5", "4", "3", "2"
            };

            var visitor = new TrackingVisitor <KeyValuePair <string, int> >();

            bag.AcceptVisitor <KeyValuePair <string, int> >(visitor);

            Assert.AreEqual(visitor.TrackingList.Count, 4);
            Assert.IsTrue(visitor.TrackingList.Contains(new KeyValuePair <string, int>("5", 1)));
            Assert.IsTrue(visitor.TrackingList.Contains(new KeyValuePair <string, int>("4", 1)));
            Assert.IsTrue(visitor.TrackingList.Contains(new KeyValuePair <string, int>("3", 1)));
            Assert.IsTrue(visitor.TrackingList.Contains(new KeyValuePair <string, int>("2", 1)));
        }
Ejemplo n.º 8
0
        public void Simple()
        {
            var bag = new Bag <string> {
                "5", "4", "3", "2"
            };

            var visitor = new TrackingVisitor <string>();

            bag.AcceptVisitor <string>(visitor);

            Assert.AreEqual(visitor.TrackingList.Count, 4);
            Assert.IsTrue(visitor.TrackingList.Contains("5"));
            Assert.IsTrue(visitor.TrackingList.Contains("4"));
            Assert.IsTrue(visitor.TrackingList.Contains("3"));
            Assert.IsTrue(visitor.TrackingList.Contains("2"));
        }
Ejemplo n.º 9
0
        public void AcceptVisitorExample()
        {
            // Create a Bag
            var bag = new Bag <string>
            {
                "cat",
                "dog",
                "canary"
            };

            // There should be 3 items in the bag.
            Assert.AreEqual(3, bag.Count);

            // Create a visitor that will simply count the items in the bag.
            var visitor = new CountingVisitor <string>();

            // Make bag call IVisitor<T>.Visit on all items contained.
            bag.AcceptVisitor <string>(visitor);

            // The counting visitor would have visited 3 items.
            Assert.AreEqual(3, visitor.Count);
        }
Ejemplo n.º 10
0
        public void AcceptVisitorExample()
        {
            // Create a Bag
            var bag = new Bag<string>
                      	{
                      		"cat",
                      		"dog",
                      		"canary"
                      	};

            // There should be 3 items in the bag.
            Assert.AreEqual(3, bag.Count);

            // Create a visitor that will simply count the items in the bag.
            var visitor = new CountingVisitor<string>();

            // Make bag call IVisitor<T>.Visit on all items contained.
            bag.AcceptVisitor<string>(visitor);

            // The counting visitor would have visited 3 items.
            Assert.AreEqual(3, visitor.Count);
        }
Ejemplo n.º 11
0
        public void ExceptionInvalid1()
        {
            var bag = new Bag <string>();

            bag.AcceptVisitor <string>(null);
        }
Ejemplo n.º 12
0
 public void ExceptionNullVisitor1()
 {
     var bag = new Bag<string>();
     bag.AcceptVisitor<string>(null);
 }
Ejemplo n.º 13
0
        public void ExceptionInvalid1()
        {
            var bag = new Bag <string>();

            Assert.Throws <ArgumentNullException>(() => bag.AcceptVisitor <string>(null));
        }