Sha256: f0795b5629fee7328f55ddacfa19745c9d04cd3ee197332ec1844471e2a95974

Contents?: true

Size: 1.09 KB

Versions: 29

Compression:

Stored size: 1.09 KB

Contents

using System;
using System.Text.RegularExpressions;
using Humanizer;

namespace Generators.Output
{
    public static class NameExtensions
    {
        public static string ToExerciseName(this Type exerciseType) => exerciseType.Name.Kebaberize();

        public static string ToTestClassName(this string input) => $"{input.Dehumanize()}Test";

        public static string ToTestedClassName(this string input) => input.Dehumanize();

        public static string ToTestMethodName(this string input)
        {
            var methodName = 
                Regex.Replace(input.Replace(":", " is"), @"[^\w]+", "_", RegexOptions.Compiled)
                    .Underscore()
                    .Transform(To.TitleCase);

            if (char.IsDigit(methodName[0]))
                return "Number_" + methodName;

            if (!char.IsLetter(methodName[0]))
                return "Test_";

            return methodName;
        }

        public static string ToTestedMethodName(this string input) => input.Dehumanize();

        public static string ToVariableName(this string input) => input.Camelize();
    }
}

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
trackler-2.2.1.14 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.13 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.12 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.11 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.10 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.9 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.8 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.7 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.6 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.5 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.4 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.3 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.2 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.1 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.0 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.0.6 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.0.5 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.0.4 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.0.3 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.0.2 tracks/csharp/generators/Output/NameExtensions.cs