Ejemplo n.º 1
0
        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..]}");
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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]))
Ejemplo n.º 4
0
 public GeneratorConfig(uint numAdjectives, string delimiter, CaseStyle caseStyle)
 {
     NumAdjectives = numAdjectives;
     Delimiter     = delimiter;
     CaseStyle     = caseStyle;
 }