예제 #1
0
            public void AcceptMethodCallsOnlyVisitOnVisitorWithThisAndNoOtherVisitMethods()
            {
                var lhs = new ConstantExpr(1);
                var rhs = new ConstantExpr(2);

                var target = new MultExpr(lhs, rhs);
                // throw exception is any other methods called other than the MultExpr overload.
                var visitor = new Mock<IExpressionVisitor<string, int>>(MockBehavior.Strict);
                visitor.Setup(x => x.Visit(It.IsAny<MultExpr>(), It.IsAny<int>())).Returns("");

                target.Accept(visitor.Object, 2);
            }
예제 #2
0
            public void AcceptMethodCallsVisitOnVisitorWithThis()
            {
                var lhs = new ConstantExpr(1);
                var rhs = new ConstantExpr(2);

                var target  = new MultExpr(lhs, rhs);
                var visitor = new Mock <IExpressionVisitor <string, int> >();

                target.Accept(visitor.Object, 0);

                visitor.Verify(x => x.Visit(target, 0), Times.Once);
            }
예제 #3
0
            public void AcceptMethodCallsVisitOnVisitorWithThis()
            {
                var lhs = new ConstantExpr(1);
                var rhs = new ConstantExpr(2);

                var target = new MultExpr(lhs, rhs);
                var visitor = new Mock<IExpressionVisitor<string, int>>();

                target.Accept(visitor.Object,0);

                visitor.Verify(x => x.Visit(target, 0), Times.Once);
            }
예제 #4
0
            public void AcceptMethodCallsOnlyVisitOnVisitorWithThisAndNoOtherVisitMethods()
            {
                var lhs = new ConstantExpr(1);
                var rhs = new ConstantExpr(2);

                var target = new MultExpr(lhs, rhs);
                // throw exception is any other methods called other than the MultExpr overload.
                var visitor = new Mock <IExpressionVisitor <string, int> >(MockBehavior.Strict);

                visitor.Setup(x => x.Visit(It.IsAny <MultExpr>(), It.IsAny <int>())).Returns("");

                target.Accept(visitor.Object, 2);
            }