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.0.8.43 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.0.8.42 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.0.8.41 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.0.8.40 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.0.8.39 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.0.8.38 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.0.8.37 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.0.8.36 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.0.8.35 tracks/csharp/generators/Methods/TestMethodRenderer.cs
trackler-2.0.8.34 tracks/csharp/generators/Methods/TestMethodRenderer.cs