Esempio n. 1
0
        public void GetTransformer_ForGenericMethodInfo()
        {
            var genericMethodDefinition = (from m in typeof(Queryable).GetMethods()
                                           where m.Name == "Distinct" && m.GetParameters().Length == 1
                                           select m).Single();
            var closedGenericMethod  = genericMethodDefinition.MakeGenericMethod(typeof(Cook));
            var methodCallExpression = Expression.Call(closedGenericMethod, Expression.Constant(null, typeof(IQueryable <>).MakeGenericType(typeof(Cook))));

            _methodCallTransformerRegistry.Register(genericMethodDefinition, _transformerStub);

            var result = _methodCallTransformerRegistry.GetTransformer(methodCallExpression);

            Assert.That(result, Is.SameAs(_transformerStub));
        }
Esempio n. 2
0
        public void GetTransformer_DontFindGenerator_ReturnsNull()
        {
            var methodCallSqlGeneratorRegistry = new MethodInfoBasedMethodCallTransformerRegistry();
            var methodCallExpression           = Expression.Call(_methodInfo, Expression.Constant("a"), Expression.Constant("b"));

            var result = methodCallSqlGeneratorRegistry.GetTransformer(methodCallExpression);

            Assert.That(result, Is.Null);
        }
Esempio n. 3
0
        public void GetTransformer()
        {
            var methodCallSqlGeneratorRegistry = new MethodInfoBasedMethodCallTransformerRegistry();

            methodCallSqlGeneratorRegistry.Register(_methodInfo, _transformerStub);
            var methodCallExpression = Expression.Call(_methodInfo, Expression.Constant("a"), Expression.Constant("b"));

            var result = methodCallSqlGeneratorRegistry.GetTransformer(methodCallExpression);

            Assert.That(result, Is.SameAs(_transformerStub));
        }
    public void GetTransformer_DontFindGenerator_ReturnsNull ()
    {
      var methodCallSqlGeneratorRegistry = new MethodInfoBasedMethodCallTransformerRegistry ();
      var methodCallExpression = Expression.Call (_methodInfo, Expression.Constant ("a"), Expression.Constant ("b"));

      var result = methodCallSqlGeneratorRegistry.GetTransformer (methodCallExpression);

      Assert.That (result, Is.Null);
    }
    public void GetTransformer ()
    {
      var methodCallSqlGeneratorRegistry = new MethodInfoBasedMethodCallTransformerRegistry ();
      methodCallSqlGeneratorRegistry.Register (_methodInfo, _transformerStub);
      var methodCallExpression = Expression.Call (_methodInfo, Expression.Constant ("a"), Expression.Constant ("b"));

      var result = methodCallSqlGeneratorRegistry.GetTransformer (methodCallExpression);

      Assert.That (result, Is.SameAs (_transformerStub));
    }