Пример #1
0
        public void FillInterfacePropertyTemplate_ValuesGiven_TemplateFilledWithValues()
        {
            _internalStorage.GetEmbeddedResource("TypeGen.Core.Templates.InterfaceProperty.tpl")
            .Returns("$tg{name} | $tg{modifier} | $tg{type}");
            var templateService = new TemplateService(_internalStorage)
            {
                GeneratorOptions = new GeneratorOptions()
            };

            string actualOptional    = templateService.FillInterfacePropertyTemplate("a", "B", true);
            string actualNonOptional = templateService.FillInterfacePropertyTemplate("a", "B", false);

            Assert.Equal("a | ? | B", actualOptional);
            Assert.Equal("a |  | B", actualNonOptional);
        }
Пример #2
0
        public void FillInterfacePropertyTemplate_ValuesGiven_TemplateFilledWithValues()
        {
            //arrange
            var generatorOptionsProvider = new GeneratorOptionsProvider {
                GeneratorOptions = new GeneratorOptions()
            };

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

            //act
            string actualOptional    = templateService.FillInterfacePropertyTemplate("a", "B", "c", true);
            string actualNonOptional = templateService.FillInterfacePropertyTemplate("a", "B", "c", false);

            //assert
            Assert.Equal("a | B? | : c", actualOptional);
            Assert.Equal("a | B | : c", actualNonOptional);
        }
Пример #3
0
        public void FillInterfacePropertyTemplate_SpecialCharsPresent_SpecialCharsReplaced()
        {
            _internalStorage.GetEmbeddedResource("TypeGen.Core.Templates.InterfaceProperty.tpl")
            .Returns("$tg{tab} | $tg{quot}");
            var generatorOptions = new GeneratorOptions {
                TabLength = 3
            };
            var templateService = new TemplateService(_internalStorage)
            {
                GeneratorOptions = generatorOptions
            };

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

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

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