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.180 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.179 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.178 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.177 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.176 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.175 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.174 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.173 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.172 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.171 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.170 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.169 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.167 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.166 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.165 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.164 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.163 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.162 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.161 tracks/csharp/generators/Output/NameExtensions.cs
trackler-2.2.1.160 tracks/csharp/generators/Output/NameExtensions.cs