private static string FormatWord(string word, CaseStyle caseStyle) { switch (caseStyle) { case CaseStyle.UpperCase: return(word.ToUpper()); case CaseStyle.TitleCase: return($"{word[0].ToString().ToUpper()}{word[1..]}");
public void Generate_ConfigHasCaseStyle_IdHasRightCaseStyle(CaseStyle inputCaseStyle, string expectedResult) { var config = GeneratorConfig.Default; config.CaseStyle = inputCaseStyle; _sut = new ZooIdGenerator(config, _testSeed); var id = _sut.GenerateId(); Assert.IsTrue(id.Equals(expectedResult)); }
public static string ToCase(this string value, CaseStyle caseStyle) { // get words var words = new List <string>(); var wordBuilder = new StringBuilder(); foreach (var c in value) { // IF UPPERCASE if (char.IsUpper(c)) { // buat baru jika sebelumnya bukan upper if (wordBuilder.Length > 0 && !char.IsUpper(wordBuilder[^ 1]))
public GeneratorConfig(uint numAdjectives, string delimiter, CaseStyle caseStyle) { NumAdjectives = numAdjectives; Delimiter = delimiter; CaseStyle = caseStyle; }