Beispiel #1
0
        public void FillEnumTemplate_ValuesGiven_TemplateFilledWithValues()
        {
            _internalStorage.GetEmbeddedResource("TypeGen.Core.Templates.Enum.tpl")
            .Returns("$tg{imports} | $tg{name} | $tg{values} | $tg{modifiers}");
            var templateService = new TemplateService(_internalStorage)
            {
                GeneratorOptions = new GeneratorOptions()
            };

            string actualConst    = templateService.FillEnumTemplate("a", "B", "c", true);
            string actualNotConst = templateService.FillEnumTemplate("a", "B", "c", false);

            Assert.Equal("a | B | c |  const", actualConst);
            Assert.Equal("a | B | c | ", actualNotConst);
        }
Beispiel #2
0
        public void FillEnumTemplate_SpecialCharsPresent_SpecialCharsReplaced()
        {
            _internalStorage.GetEmbeddedResource("TypeGen.Core.Templates.Enum.tpl")
            .Returns("$tg{tab} | $tg{quot}");
            var generatorOptions = new GeneratorOptions {
                TabLength = 3
            };
            var templateService = new TemplateService(_internalStorage)
            {
                GeneratorOptions = generatorOptions
            };

            string actualDoubleQuote = templateService.FillEnumTemplate("", "", "", false);

            generatorOptions.SingleQuotes = true;
            string actualSingleQuote = templateService.FillEnumTemplate("", "", "", false);

            Assert.Equal("    | \"", actualDoubleQuote);
            Assert.Equal("    | '", actualSingleQuote);
        }