Ejemplo n.º 1
0
        public void FillClassDefaultExportTemplate_SpecialCharsPresent_SpecialCharsReplaced()
        {
            //arrange
            var generatorOptions = new GeneratorOptions {
                TabLength = 3
            };
            var generatorOptionsProvider = new GeneratorOptionsProvider {
                GeneratorOptions = generatorOptions
            };

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

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

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

            //assert
            Assert.Equal("    | \"", actualDoubleQuote);
            Assert.Equal("    | '", actualSingleQuote);
        }
Ejemplo n.º 2
0
        public void FillClassDefaultExportTemplate_ValuesGiven_TemplateFilledWithValues()
        {
            //arrange
            var generatorOptionsProvider = new GeneratorOptionsProvider {
                GeneratorOptions = new GeneratorOptions()
            };

            _internalStorage.GetEmbeddedResource("TypeGen.Core.Templates.ClassDefaultExport.tpl")
            .Returns("$tg{imports} | $tg{name} | $tg{exportName} | $tg{extends} | $tg{properties} | $tg{customHead} | $tg{customBody}");
            var templateService = new TemplateService(_internalStorage, generatorOptionsProvider);

            //act
            string actual = templateService.FillClassDefaultExportTemplate("a", "B", "c", "D", "e", "F", "g");

            //assert
            Assert.Equal("a | B | c | D | e | F | g", actual);
        }