Sha256: 93255ccd7fe06885f5ef0f779f9e23c9ee8531d2816e99a6d4004db818b0e052

Contents?: true

Size: 789 Bytes

Versions: 70

Compression:

Stored size: 789 Bytes

Contents

using System.Linq;

namespace Generators.Methods
{
    public static class TestMethodRenderer
    {
        private const string Tab = "    ";

        private const string TestMethodTemplate =
@"{Tab}[Fact{Skip}]
{Tab}public void {Name}()
{Tab}{
{Body}
{Tab}}";

        public static string Render(TestMethod testMethod) =>
            TestMethodTemplate
                .Replace("{Tab}", Tab)
                .Replace("{Name}", testMethod.MethodName)
                .Replace("{Body}", RenderBody(testMethod))
                .Replace("{Skip}", testMethod.Index == 0 ? "" : "(Skip = \"Remove to run test\")");

        private static string RenderBody(TestMethod testMethod) 
            => string.Join("\n", testMethod.Body.Split('\n').Select(line => $"{Tab}{Tab}{line}"));
    }
}

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
trackler-2.1.0.48 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.1.0.47 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.1.0.46 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.1.0.45 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.1.0.44 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.1.0.43 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.1.0.42 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.1.0.41 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.1.0.40 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.1.0.39 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.1.0.38 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.1.0.37 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.1.0.36 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.1.0.34 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.1.0.33 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.1.0.32 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.1.0.31 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.1.0.30 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.1.0.29 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.1.0.28 tracks/csharp/generators/Methods/TestMethodRenderer.cs