Exemplo n.º 1
0
        protected override void BuildArrangeSourceCode(MethodSourceCodeGenerationRequest request)
        {
            var method = request.Method;

            if (method.IsStatic)
            {
                return;
            }
            string variableName;

            if (testMethodValueProvider.HasVariableForTestedType(method.ReflectedType, out variableName))//referencing existing variable
            {
                InstanceExpression = Expression.Variable(method.ReflectedType, variableName);
            }
            else
            {
                ParameterExpression instanceExpression;
                var assignExpr = expressionBuilder.BuildInstanceCreationWithAssigmentExpression(method.ReflectedType, out instanceExpression);
                InstanceExpression = instanceExpression;
                Append("var ");
                var expresionAsString = expressionBuilder.ExpressionToString(assignExpr);
                Append(expresionAsString.RemoveParantheses());
                AppendLine(";");
            }
        }