//protected override Expression BuildCallExpression(MethodSourceCodeGenerationRequest request)
        //{
        //    var method = request.Method;
        //    var callExpression = base.BuildCallExpression(request);
        //    var lambda = Expression.Lambda(typeof(Action<>).MakeGenericType(method.ReflectedType), callExpression, paramExpression);
        //    var invokeGenericMethod = ((MethodCallExpression)invokingActionMethod.Body).Method.GetGenericMethodDefinition().MakeGenericMethod(method.ReflectedType);
        //    var invokeExpr = Expression.Call(null, invokeGenericMethod, InstanceExpression, lambda);
        //}
        protected override void BuildActSourceCode(MethodSourceCodeGenerationRequest request)
        {
            var method = request.Method;

            var arguments = expressionBuilder.CreateArgumentExpressions(method.GetParameters(), request.NullArgumentNeedsExplicitCast, request.ParameterDestinedAsNull);
            MethodCallExpression invokeExpr = expressionBuilder.BuildFluentAssertionMethodInvokingExpression(method, InstanceExpression, arguments);

            Append(expressionBuilder.ExpressionToString(invokeExpr));
            AppendLine(";");
        }
 public IEnumerable<TestMethod> GenerateTestMethods(TypeContext typeContext)
 {
     foreach (var method in GetMethods(typeContext))
     {
         var request = new MethodSourceCodeGenerationRequest(method, true, method.GetParameters().First());
         var methodName = sourceCodeGenerator.BuildMethodName(request);
         var sourceCode = sourceCodeGenerator.BuildSourceCode(request);
         yield return new TestMethod(method, methodName, sourceCode);
     }
 }
        public void BuildSourceCode2()
        {
            const string expr = "expr1";
            var sampleInstance = new TestAssembly.OverloadedMethods("");
            TestMethod methodDelegate = sampleInstance.OverloadedMethod;
            var expressionBuilder = MockRepository.GenerateMock<IFluentAssertionExpressionBuilder>();
            expressionBuilder.Stub(m => m.ExpressionToString(null))
                .IgnoreArguments()
                .Return(expr);
            var testee = new FluentAssertionNullArgumentMethodTestMethodSourceCodeGenerator(expressionBuilder,
                MockRepository.GenerateMock<ITestMethodValueProvider>());
            var request = new MethodSourceCodeGenerationRequest(methodDelegate.Method);

            var result = testee.BuildSourceCode(request);

            result.Should().Be($@"var {expr};{Environment.NewLine}{expr};{Environment.NewLine}");
        }
 public override string BuildMethodName(MethodSourceCodeGenerationRequest request)
 {
     return request.Method.Name + Guid.NewGuid().ToString().Substring(0, 8);
 }