public void GetProposedNameTest()
 {
     Assert.AreEqual("TestRequest", RequestClassGenerator.GetProposedName(
                         new MockMethod()
     {
         Name = "Test"
     },
                         RequestClassGenerator.RequestClassNamingScheme));
     Assert.AreEqual("AbcRequest", RequestClassGenerator.GetProposedName(
                         new MockMethod()
     {
         Name = "abc"
     },
                         RequestClassGenerator.RequestClassNamingScheme));
 }
            public CodeMemberMethod CreateMethod(CodeTypeDeclaration classDeclaration,
                                                 IResource resource,
                                                 IMethod method,
                                                 bool addOptionalParameters,
                                                 MethodType methodType)
            {
                // Create a new method and make it public.
                var member = new CodeMemberMethod();

                member.Name       = GeneratorUtils.GetMethodName(method, resource.Methods.Keys.Without(method.Name));
                member.Attributes = MemberAttributes.Public;
                if (commentCreator != null)
                {
                    member.Comments.AddRange(commentCreator.CreateMethodComment(method));
                }

                // Check if this method has a body.
                CodeExpressionCollection constructorParameters = new CodeExpressionCollection();

                constructorParameters.Add(new CodeVariableReferenceExpression(ServiceFieldName));
                if (method.HasBody)
                {
                    // If so, add a body parameter.
                    ResourceCallAddBodyDeclaration(method, member, GetBodyType(method), false);
                }

                // If a body parameter or similar parameters were added, also add them to the constructor.
                foreach (CodeParameterDeclarationExpression existingParameter in member.Parameters)
                {
                    constructorParameters.Add(new CodeVariableReferenceExpression(existingParameter.Name));
                }

                // Add all request parameters to this method.
                AddDeclaredParameters(
                    classDeclaration, method, member, constructorParameters, addOptionalParameters);

                string requestClassNamingScheme = RequestClassGenerator.RequestClassNamingScheme;

                // If this is the media-upload convenience method, add the stream and content-type
                // parameters.
                if (methodType == MethodType.Media)
                {
                    member.Parameters.Add(new CodeParameterDeclarationExpression(
                                              typeof(System.IO.Stream), StreamParameterName));
                    member.Parameters.Add(new CodeParameterDeclarationExpression(
                                              typeof(System.String), ContentTypeParameterName));

                    constructorParameters.Add(new CodeVariableReferenceExpression(StreamParameterName));
                    constructorParameters.Add(new CodeVariableReferenceExpression(ContentTypeParameterName));

                    requestClassNamingScheme = RequestClassGenerator.MediaUploadClassNamingScheme;
                }

                // new ...Request(paramOne, paramTwo, paramThree)
                // TODO(mlinder): add method signature collision checking here.
                CodeTypeReference requestType = new CodeTypeReference(
                    RequestClassGenerator.GetProposedName(
                        method, requestClassNamingScheme));

                member.ReturnType = requestType;
                var newRequest = new CodeObjectCreateExpression(requestType);

                newRequest.Parameters.AddRange(constructorParameters);

                // return ...;
                var returnStatment = new CodeMethodReturnStatement(newRequest);

                member.Statements.Add(returnStatment);

                return(member);
            }