public void Translate_TwoParameters_RendersCorrectly()
        {
            // Arrange

            var visitor = new Mock <N1QlExpressionTreeVisitor>(new N1QlQueryGenerationContext())
            {
                CallBase = true
            };

            var method     = typeof(Methods).GetMethod("Method2");
            var expression = Expression.Call(method,
                                             Expression.Constant("arg1"),
                                             Expression.Constant("arg2"));

            var transformer = new N1QlFunctionMethodCallTranslator(method, new N1QlFunctionAttribute("FUNC"));

            // Act

            transformer.Translate(expression, visitor.Object);
            var result = visitor.Object.GetN1QlExpression();

            // Assert

            Assert.AreEqual("FUNC(\"arg1\", \"arg2\")", result);
        }
        public void Translate_NoVisitor_ThrowsArgumentNullException()
        {
            // Arrange

            var method     = typeof(Methods).GetMethod("Method0");
            var expression = Expression.Call(method);

            var transformer = new N1QlFunctionMethodCallTranslator(method, new N1QlFunctionAttribute("FUNC"));

            // Act/Assert

            var result = Assert.Throws <ArgumentNullException>(() => transformer.Translate(expression, null));

            Assert.AreEqual("expressionTreeVisitor", result.ParamName);
        }
        public void SupportedMethods_ReturnsMethodInfoFromConstructor()
        {
            // Arrange

            var method = typeof(Methods).GetMethod("Method0");

            var translator = new N1QlFunctionMethodCallTranslator(method, new N1QlFunctionAttribute("FUNC"));

            // Act

            var result = new List <MethodInfo>(translator.SupportMethods);

            // Assert

            Assert.Contains(method, result);
        }
        public void Translate_NoMethod_ThrowsArgumentNullException()
        {
            // Arrange

            var visitor = new Mock <N1QlExpressionTreeVisitor>(new N1QlQueryGenerationContext())
            {
                CallBase = true
            };

            var method = typeof(Methods).GetMethod("Method0");

            var transformer = new N1QlFunctionMethodCallTranslator(method, new N1QlFunctionAttribute("FUNC"));

            // Act/Assert

            var result = Assert.Throws <ArgumentNullException>(() => transformer.Translate(null, visitor.Object));

            Assert.AreEqual("methodCallExpression", result.ParamName);
        }