public static MethodDeclarationSyntax CreateTestMethod(this MethodDeclarationSyntax methodDeclarationSyntax, SemanticModel model) { var method = model.GetDeclaredSymbol(methodDeclarationSyntax); var methodName = method.Name; var className = method.ContainingType.Name; var arguments = method.Parameters.ToTypedArguments(); var returnValue = !method.ReturnsVoid || ((method.ReturnType as INamedTypeSymbol).IsGenericType) ? "var result = " : ""; var mockSetups = methodDeclarationSyntax.CreateMockSetups(model); var statements = new List <StatementSyntax>(mockSetups) { ParseStatement($"{returnValue}{(method.IsAsync ? "await" : "")} {className.ToMemberName()}.{methodName}({arguments});") .AddLeadingNewLine(mockSetups.Any()) .AddTrailingNewLine(mockSetups.Any()) }; statements.AddRange(methodDeclarationSyntax.CreateVerifyAllForMocks(model)); var methodDeclaration = (ParseMemberDeclaration($"[Fact]public {(method.IsAsync ? "async Task" : "void")} {methodName.ToTestMethodName()}()") as MethodDeclarationSyntax); return(methodDeclaration.WithBody(Block(statements))); }