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"));
        }
Exemple #2
0
 public abstract void VisitConcreteElementA(ConcreteElementA concreteElementA);
Exemple #3
0
 public override void VisitConcreteElementA(ConcreteElementA concreteElementA)
 {
     Console.WriteLine("{0} visited by {1}", concreteElementA.GetType().Name, this.GetType().Name);
 }