예제 #1
0
        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));
        }
예제 #2
0
        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);
        }
예제 #3
0
            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);
            }