public void ConcreteVisitorATest() { ConcreteVisitorA visitor = new ConcreteVisitorA(); Element composition = BuildComposition(); composition.Accept(visitor); Assert.AreEqual(5, visitor.VisitCount); }
static void Main(string[] args) { //Hero h = new Ninja(); //HeroDecorator hd1 = new Knife(); //HeroDecorator hd3 = new Knife(); //HeroDecorator hd2 = new Armor(); //hd1.SetComponent(h); //hd2.SetComponent(hd1); //hd3.SetComponent(hd2); //var a = hd3.getArmor(); //var b = hd3.getDamage(); //TV receiver = new TV(); //Remote invoker = new Remote(); //Commanda command = new VolumeUp(receiver); //invoker.SetCommand(command); //invoker.Invoke(); //Context cont = new Context(); //Strategy.Strategy qstrategy = new QuickSort(); //Strategy.Strategy istrategy = new InsertionSort(); //cont.SetStrategy(qstrategy); Visitor.Visitor v1 = new ConcreteVisitorA(); Visitor.Visitor v2 = new ConcreteVisitorB(); Visitor.Person s = new Student(); Visitor.Person p = new Profesor(); ObjectStructure o = new ObjectStructure(); o.Attach(s); o.Attach(p); o.Accept(v1); o.Accept(v2); ChatMediator m = new ChatMediator(); User1 u1 = new User1(m); User2 u2 = new User2(m); m.user1 = new User1(m); m.user2 = new User2(m); Console.ReadLine(); }
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")); }