private string GenPrivateClassesAtTop()
        {
            var frmtStr     = Spacing.Get(2) + "private {0} {1};\r\n";
            var str         = string.Empty;
            var substitutes = string.Empty;

            foreach (var className in _parts.PrivateClassesAtTop)
            {
                var privClassName = DTEHelper.GenPrivateClassNameAtTop(className);
                str += string.Format(frmtStr, className, privClassName);
                // _parts.InitCode = string.Format("{0}{1} = Substitute.For<{2}>();\r\n", Spacing.Get(3), privClassName, className) + _parts.InitCode;
                substitutes += string.Format("{0}{1} = Substitute.For<{2}>();\r\n", Spacing.Get(3), privClassName, className);
            }

            if (string.IsNullOrWhiteSpace(substitutes) == false)
            {
                substitutes += "\r\n";
            }

            _parts.InitCode = substitutes + _parts.InitCode;

            if (_parts.HasConstructor || _parts.IsStaticClass == false)
            {
                str += string.Format(frmtStr, _parts.SelectedClass.Name, "_testTarget");
            }

            return(str);
        }
        private string GenerateInterface(CodeParameter param)
        {
            var codeInterface = (CodeInterface)param.Type.CodeType;

            _parts.PrivateClassesAtTop.AddIfNotExists(codeInterface.Name);
            _parts.Interfaces.AddIfNotExists(codeInterface);
            AddNameSpace(param.Type.CodeType.Namespace);

            return(DTEHelper.GenPrivateClassNameAtTop(codeInterface.Name));
        }
        private string GenInterfaceMocking()
        {
            //goal
            //async   _someClass.SomeFunction(Arg.Any<Guid>()).Returns(Task.FromResult(SomeClass));
            //reg     _someClass.SomeFunction(Arg.Any<Guid>()).Returns(SomeClass);
            var str = string.Empty;

            Log("\r\nGenerating Interfaces\r\n");

            foreach (CodeInterface face in _parts.Interfaces)   //foreach interface found in our test class
            {
                if (face.Kind != vsCMElement.vsCMElementInterface)
                {
                    continue;
                }

                _genner.AddNameSpace(face.Namespace);

                foreach (CodeFunction member in face.Members.OfType <CodeFunction>()) //foreach function in interface
                {
                    try
                    {
                        var returnType = string.Empty;

                        var isAsync = member.Type.CodeType.FullName.Contains("System.Threading.Tasks.Task");

                        var strippedMember = _genner.StripGenerics(member.Type);

                        if (strippedMember == null)
                        {
                            throw new Exception("Could not strip generic");
                        }
                        if (strippedMember.TypeKind == vsCMTypeRef.vsCMTypeRefVoid || strippedMember.AsFullName == "System.Threading.Tasks.Task")
                        {
                            continue; //no need to mock return type for Void functions
                        }

                        Log(member.FullName + "\r\n");

                        if (strippedMember.TypeKind == vsCMTypeRef.vsCMTypeRefCodeType && (strippedMember.AsString != "System.Guid" && strippedMember.AsString != "System.DateTime" && strippedMember.CodeType.Kind != vsCMElement.vsCMElementEnum))
                        {
                            _genner.GenerateFunctionParamForClassInput(member.Type);
                            ////_genner.GenerateFunctionParamForClassInput(member.Type.CodeType.Name, member.Type.CodeType.FullName, member.Type); //make sure we have created this type so we can return it
                            //returnType = _parts.GetParamFunctionName(memberNoTask.CodeType.FullName) + "()";
                            returnType = _parts.GetParamFunctionName(strippedMember.CodeType.FullName);
                            if (returnType == null)
                            {
                                returnType = "new {}";
                            }
                            else
                            {
                                returnType += "()";
                            }
                        }
                        else
                        {
                            returnType = _genner.GetParamValue(member.Type, "", 0);
                        }

                        //if (returnType == "GetList()")
                        //{
                        //    var tmp5 = 5;
                        //}

                        if (isAsync)
                        {
                            returnType = string.Format("Task.FromResult({0})", returnType);
                        }

                        str += string.Format("{0}{1}.{2}({3}).Returns({4});\r\n", Spacing.Get(3), DTEHelper.GenPrivateClassNameAtTop(face.Name), member.Name, GetInterfaceArgs(member), returnType);
                    }
                    catch (Exception ex)
                    {
                        str += string.Format("{0}//Could not generate {1}.{2}; \r\n", Spacing.Get(3), face.Name, member.Name);
                    }
                }
            }

            // str = str.ReplaceLastOccurrence("\r\n", "");
            return(str);
        }