예제 #1
0
        public void FillEnumDefaultExportTemplate_ValuesGiven_TemplateFilledWithValues()
        {
            //arrange
            var generatorOptionsProvider = new GeneratorOptionsProvider {
                GeneratorOptions = new GeneratorOptions()
            };

            _internalStorage.GetEmbeddedResource("TypeGen.Core.Templates.EnumDefaultExport.tpl")
            .Returns("$tg{imports} | $tg{name} | $tg{values} | $tg{modifiers}");
            var templateService = new TemplateService(_internalStorage, generatorOptionsProvider);

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

            //assert
            Assert.Equal("a | B | c |  const", actualConst);
            Assert.Equal("a | B | c | ", actualNotConst);
        }
예제 #2
0
        public void FillEnumDefaultExportTemplate_SpecialCharsPresent_SpecialCharsReplaced()
        {
            //arrange
            var generatorOptions = new GeneratorOptions {
                TabLength = 3
            };
            var generatorOptionsProvider = new GeneratorOptionsProvider {
                GeneratorOptions = generatorOptions
            };

            _internalStorage.GetEmbeddedResource("TypeGen.Core.Templates.EnumDefaultExport.tpl")
            .Returns("$tg{tab} | $tg{quot}");
            var templateService = new TemplateService(_internalStorage, generatorOptionsProvider);

            //act
            string actualDoubleQuote = templateService.FillEnumDefaultExportTemplate("", "", "", false);

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

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