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_MismatchedMethod_ThrowsArgumentException() { // Arrange var visitor = new Mock<N1QlExpressionTreeVisitor>(new N1QlQueryGenerationContext()) { CallBase = true }; var method = typeof(Methods).GetMethod("Method1"); var expression = Expression.Call(typeof(Methods).GetMethod("Method0")); var transformer = new N1QlFunctionMethodCallTranslator(method, new N1QlFunctionAttribute("FUNC")); // Act/Assert var result = Assert.Throws<ArgumentException>(() => transformer.Translate(expression, visitor.Object)); Assert.AreEqual("methodCallExpression", result.ParamName); }
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); }