Sha256: 10f1dc38904f5adc68a3ba72d36217c278c9b1619e4f83df07d2e85f04f4cae2

Contents?: true

Size: 1.12 KB

Versions: 50

Compression:

Stored size: 1.12 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 = input
                .Replace(":", " is")
                .Replace("'", "");

            methodName = Regex.Replace(methodName, @"[^\w]+", "_", RegexOptions.Compiled)
                .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

50 entries across 50 versions & 1 rubygems

Version Path
trackler-2.2.1.64 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.63 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.62 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.61 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.60 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.59 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.58 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.57 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.56 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.55 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.54 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.53 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.52 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.51 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.50 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.49 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.48 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.47 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.46 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.45 tracks/csharp/generators/Output/NameExtensions.cs