예제 #1
0
        public void FillClassPropertyTemplate_SpecialCharsPresent_SpecialCharsReplaced()
        {
            _internalStorage.GetEmbeddedResource("TypeGen.Core.Templates.ClassProperty.tpl")
            .Returns("$tg{tab} | $tg{quot}");
            var generatorOptions = new GeneratorOptions {
                TabLength = 3
            };
            var templateService = new TemplateService(_internalStorage)
            {
                GeneratorOptions = generatorOptions
            };

            string actualDoubleQuote = templateService.FillClassPropertyTemplate("", "", "");

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

            Assert.Equal("    | \"", actualDoubleQuote);
            Assert.Equal("    | '", actualSingleQuote);
        }
예제 #2
0
        public void FillClassPropertyTemplate_ValuesGiven_TemplateFilledWithValues()
        {
            _internalStorage.GetEmbeddedResource("TypeGen.Core.Templates.ClassProperty.tpl")
            .Returns("$tg{accessor} | $tg{name} | $tg{type}");
            var templateService = new TemplateService(_internalStorage)
            {
                GeneratorOptions = new GeneratorOptions()
            };

            string actual = templateService.FillClassPropertyTemplate("a", "B", "c");

            Assert.Equal("a | B | c", actual);
        }
예제 #3
0
        public void FillClassPropertyTemplate_ValuesGiven_TemplateFilledWithValues()
        {
            //arrange
            var generatorOptionsProvider = new GeneratorOptionsProvider {
                GeneratorOptions = new GeneratorOptions()
            };

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

            //act
            string actual = templateService.FillClassPropertyTemplate("a", "B", "c", "D");

            //assert
            Assert.Equal("a | B | : c |  = D", actual);
        }