public static ClassDeclarationSyntax CreateTestClass(this ClassDeclarationSyntax classSyntax, SemanticModel semanticModel) { var memberList = new List <MemberDeclarationSyntax>(); var constructor = classSyntax.Members.OfType <ConstructorDeclarationSyntax>().FirstOrDefault(); var parameters = constructor.ParameterList.Parameters; memberList.AddRange(parameters.Select(_ => _.Type.CreateMockAsField())); memberList.Add(classSyntax.CreateMemberOfClass()); memberList.Add(classSyntax.CreateConstructor()); var methods = classSyntax.Members.OfType <MethodDeclarationSyntax>().Where(_ => _.Modifiers.Any(SyntaxKind.PublicKeyword)); memberList.AddRange(methods.Select(_ => CreateTestMethod(_, semanticModel))); var className = classSyntax.Identifier.Text; return(ClassDeclaration(className.ToTestClass()) .WithModifiers( TokenList( Token(SyntaxKind.PublicKeyword))) .WithMembers(List(memberList))); }