Ejemplo n.º 1
0
        public void Test()
        {
            var structure = new Structure();

            structure.Attach(new ConcreteElementA());
            structure.Attach(new ConcreteElementB());
            var visitorA = new ConcreteVisitorA();
            var visitorB = new ConcreteVisitorB();

            structure.Accept(visitorA);
            structure.Accept(visitorB);
        }
Ejemplo n.º 2
0
        public void Test()
        {
            Visitor visitorA = new ConcreteVisitorA();
            Visitor visitorB = new ConcreteVisitorB();

            Element elementA = new ConcreteElementA();
            Element elementB = new ConcreteElementB();

            Assert.That(elementA.Accept(visitorA), Is.EqualTo("ConcreteElementA visited by ConcreteVisitorA"));
            Assert.That(elementA.Accept(visitorB), Is.EqualTo("ConcreteElementA visited by ConcreteVisitorB"));
            Assert.That(elementB.Accept(visitorA), Is.EqualTo("ConcreteElementB visited by ConcreteVisitorA"));
            Assert.That(elementB.Accept(visitorB), Is.EqualTo("ConcreteElementB visited by ConcreteVisitorB"));
        }