public void ActionVisitor_Visit_Success() { var mock = new Mock <VisitorTests>(); IActionVisitor <Letter> visitor = Visitor.For <Letter>(); visitor.Register <A>(mock.Object.VisitAction); visitor.Register <B>(mock.Object.VisitAction); var value = new A(); visitor.Visit(value); mock.Verify(x => x.VisitAction(value)); }
private static void ActionVisitor() { Console.WriteLine("Action Visitor"); IActionVisitor <Letter> visitor = Visitor.For <Letter>(); visitor.Register <A>(x => Console.WriteLine(x.GetType().Name)); visitor.Register <B>(x => Console.WriteLine(x.GetType().Name)); Letter a = new A(); Letter b = new B(); visitor.Visit(a); visitor.Visit(b); }
public void Do() { Console.WriteLine("Action Visitor"); IActionVisitor <Letter> visitor = Visitor.For <Letter>(); visitor.Register <A>(ProcessA); visitor.Register <B>(ProcessB); Letter a = new A(); Letter b = new B(); visitor.Visit(a); visitor.Visit(b); }