Sha256: f22c26bc153e37f46edf3f236a680f81d8fe6e9091ad5b0a2a72255071943147

Contents?: true

Size: 1.21 KB

Versions: 114

Compression:

Stored size: 1.21 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.ToExerciseName();

        public static string ToExerciseName(this string input) => input.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

114 entries across 114 versions & 1 rubygems

Version Path
trackler-2.2.1.98 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.97 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.96 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.95 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.94 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.93 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.92 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.91 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.90 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.89 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.88 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.87 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.86 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.85 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.84 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.83 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.82 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.81 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.80 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.79 tracks/csharp/generators/Output/NameExtensions.cs