Exemple #1
0
        public void It_Can_Pass_Parse_Arguments()
        {
            var result1 = MustacheParser.Parse("Test {{Foo}} Test 1");
            var result2 = MustacheParser.Parse("Test {{Foo}} Test 3", new Tags("{{", "}}"));

            Assert.NotEmpty(result1.Children);
            Assert.NotEmpty(result2.Children);
        }
Exemple #2
0
        private static async Task GenerateJenkinsfileCode(CodeGenConfig config)
        {
            string fileName = "Jenkinsfile";

            string jenkinsFilePath = config.outputFolderPath + "\\" + fileName;

            dynamic jenkinsfileConfig = new JObject();

            jenkinsfileConfig.packageName = config.PackageName;

            await MustacheParser.GenerateCodeFile(fileName, jenkinsFilePath, jenkinsfileConfig);
        }
Exemple #3
0
        public void It_Knows_How_To_Parse(TestData data)
        {
            OutputStream.WriteLine($"Index: {data.Index}, Template: '{data.Name}'");
            var results = MustacheParser.Parse(data.Name);

            Assert.Equal("Root", results.Identifier);
            Assert.Equal(data.Arguments.Count, results.Children.Count);

            for (var i = 0; i < results.Children.Count; i++)
            {
                Assert.StrictEqual(data.Arguments[i], results.Children[i]);
            }
        }
Exemple #4
0
        private static async Task GenerateGitIgnoreCode(CodeGenConfig config)
        {
            string fileName      = "";
            string fileExtension = "gitignore";

            string updateAssemblyFilePath = config.outputFolderPath + "\\" + fileName + "." + fileExtension;

            dynamic updateGitIgnore = new JObject();

            updateGitIgnore.packageName = config.PackageName;

            await MustacheParser.GenerateCodeFile("gitignore", updateAssemblyFilePath, updateGitIgnore);
        }
Exemple #5
0
        private static async Task GenerateUpdateAssemblyCode(CodeGenConfig config)
        {
            string fileName      = "UpdateAssembly";
            string fileExtension = "ps1";

            string updateAssemblyFilePath = config.outputFolderPath + "\\" + fileName + "." + fileExtension;

            dynamic updateAssemblyConfig = new JObject();

            updateAssemblyConfig.packageName = config.PackageName;

            await MustacheParser.GenerateCodeFile(fileName, updateAssemblyFilePath, updateAssemblyConfig);
        }
Exemple #6
0
        private static async Task GeneratePipelineCode(CodeGenConfig config)
        {
            string fileName      = "pipeline";
            string fileExtension = "yml";

            string pipelineFilePath = config.outputFolderPath + "\\" + fileName + "." + fileExtension;

            dynamic pipelineConfig = new JObject();

            pipelineConfig.packageName = config.PackageName;

            await MustacheParser.GenerateCodeFile(fileName, pipelineFilePath, pipelineConfig);
        }
Exemple #7
0
        private static async Task GenerateDockerfileCode(CodeGenConfig config, WebApiProjectStructure webApiProjectStructure)
        {
            string fileName = "Dockerfile";

            string dockerFilePath = config.outputFolderPath + "\\src\\" + config.PackageName + "." + webApiProjectStructure.RootWebAPIProjectNameSuffix + "\\" + fileName;

            dynamic dockerConfig = new JObject();

            dockerConfig.packageName      = config.PackageName + "." + webApiProjectStructure.RootWebAPIProjectNameSuffix;
            dockerConfig.donotcoreVersion = webApiProjectStructure.DotnetCoreVersion;


            await MustacheParser.GenerateCodeFile(fileName, dockerFilePath, dockerConfig);
        }
Exemple #8
0
        private static async Task GenerateStartupCode(CodeGenConfig config, WebApiProjectStructure webApiProjectStructure)
        {
            string csprojAPIPath = config.outputFolderPath + "\\src\\" + config.PackageName + "." + webApiProjectStructure.RootWebAPIProjectNameSuffix + "\\" + config.PackageName + "." + webApiProjectStructure.RootWebAPIProjectNameSuffix + ".csproj";
            string fileName      = "Startup";
            string fileExtension = "cs";

            string startupFilePath = config.outputFolderPath + "\\src\\" + config.PackageName + "." + webApiProjectStructure.RootWebAPIProjectNameSuffix + "\\" + fileName + "." + fileExtension;

            dynamic startupConfig = new JObject();

            if (config.UseCircuitbreaker == true)
            {
                startupConfig.isPolly = true;

                //Add Polly Package to Web API Project
                await CodeGenerationCoreOperations.AddPackageToProject(csprojAPIPath, webApiProjectStructure.PollyWebApiPackage.PackageName, webApiProjectStructure.PollyWebApiPackage.Version);
            }

            if (config.UseLogging == true)
            {
                startupConfig.isSteeltoe = true;

                //Add Steeltoe Package to Web API Project
                await CodeGenerationCoreOperations.AddPackageToProject(csprojAPIPath, webApiProjectStructure.SteeltoeWebApiPackage.PackageName, webApiProjectStructure.SteeltoeWebApiPackage.Version);
            }

            if (config.Database == EnumDatabase.MongoDB)
            {
                startupConfig.isMongo             = true;
                startupConfig.mongoConnectionName = config.PackageName + "MongoConnectionString";
                //Add Mongo Package
                await CodeGenerationCoreOperations.AddPackageToProject(csprojAPIPath, webApiProjectStructure.MongoDBDriver.PackageName, webApiProjectStructure.MongoDBDriver.Version);

                await CodeGenerationCoreOperations.AddPackageToProject(csprojAPIPath, webApiProjectStructure.MongoDBDriverCore.PackageName, webApiProjectStructure.MongoDBDriverCore.Version);

                await CodeGenerationCoreOperations.AddPackageToProject(csprojAPIPath, webApiProjectStructure.MongoBSON.PackageName, webApiProjectStructure.MongoBSON.Version);

                await CodeGenerationCoreOperations.AddPackageToProject(csprojAPIPath, webApiProjectStructure.MongoHealthCheck.PackageName, webApiProjectStructure.MongoHealthCheck.Version);
            }
            startupConfig.packageName = config.PackageName;
            startupConfig.apiTitle    = config.PackageName + " " + webApiProjectStructure.RootWebAPIProjectNameSuffix;
            startupConfig.apiVersion  = webApiProjectStructure.ApiVersion;


            await MustacheParser.GenerateCodeFile(fileName, startupFilePath, startupConfig);
        }
Exemple #9
0
        private static async Task GenerateDeploymentManifestCode(CodeGenConfig config)
        {
            string fileName      = "deployit-manifest";
            string fileExtension = "xml";

            string deploymentManifestFilePath = config.outputFolderPath + "\\" + fileName + "." + fileExtension;

            dynamic deploymentManifestConfig = new JObject();

            deploymentManifestConfig.packageName          = config.PackageName;
            deploymentManifestConfig.packageNameLowerCase = config.PackageName.ToLower();
            deploymentManifestConfig.websiteName          = "{{NET_ECOMMERCE-API-" + config.PackageName.ToUpper() + "_WEBSITE_NAME}}";
            deploymentManifestConfig.websitePhysicalPath  = "{{NET_ECOMMERCE-API-" + config.PackageName.ToUpper() + "_WEBSITE_PHYSICALPATH}}";


            await MustacheParser.GenerateCodeFile(fileName, deploymentManifestFilePath, deploymentManifestConfig);
        }
Exemple #10
0
        private static async Task GenerateAppSettings(CodeGenConfig config, WebApiProjectStructure webApiProjectStructure)
        {
            string fileName      = "appsettings";
            string fileExtension = "json";

            string appSettingsPath = config.outputFolderPath + "\\src\\" + config.PackageName + "." + webApiProjectStructure.RootWebAPIProjectNameSuffix + "\\" + fileName + "." + fileExtension;

            dynamic appSettingsConfig = new JObject();

            if (config.Database == EnumDatabase.MongoDB)
            {
                appSettingsConfig.isMongo             = true;
                appSettingsConfig.mongoConnectionName = config.PackageName + "MongoConnectionString";
            }

            if (config.Database == EnumDatabase.Oracle)
            {
                appSettingsConfig.isOracle             = true;
                appSettingsConfig.oracleConnectionName = config.PackageName + "OracleConnectionString";
            }
            if (config.Messaging.Contains("kafka"))
            {
                appSettingsConfig.isKafka = true;
            }
            else
            {
                appSettingsConfig.isKafka = false;
            }
            if (config.Messaging.Contains("ibmmq"))
            {
                appSettingsConfig.isIBMMq = true;
            }
            else
            {
                appSettingsConfig.isIBMMq = false;
            }


            await MustacheParser.GenerateCodeFile(fileName, appSettingsPath, appSettingsConfig);
        }
Exemple #11
0
 public void Static_MustacheParser_Throws_On_Null()
 {
     Assert.Throws <ArgumentNullException>(() => MustacheParser.Parse(null));
 }
Exemple #12
0
        public void It_Errors_When_You_Close_The_Wrong_Section()
        {
            var ex = Assert.Throws <StubbleException>(() => { MustacheParser.Parse("{{#Section}}Herp De Derp{{/WrongSection}}"); });

            Assert.Equal("Cannot close Block 'WrongSection' at 24. There is already an unclosed Block 'Section'", ex.Message);
        }
Exemple #13
0
        public void It_Knows_When_There_Is_An_Unopened_Section()
        {
            var ex = Assert.Throws <StubbleException>(() => { MustacheParser.Parse("The end of the list! {{/people}}"); });

            Assert.Equal("Unopened Block 'people' at 21", ex.Message);
        }
Exemple #14
0
        public void It_Knows_When_There_Is_An_Unclosed_Section()
        {
            var ex = Assert.Throws <StubbleException>(() => { MustacheParser.Parse("A list: {{#people}}{{Name}}"); });

            Assert.Equal("Unclosed Block 'people' at 27", ex.Message);
        }
Exemple #15
0
        public void It_Knows_When_There_Is_An_Unclosed_Tag()
        {
            var ex = Assert.Throws <StubbleException>(() => { MustacheParser.Parse("My Name is {{Name"); });

            Assert.Equal("Unclosed Tag at 17", ex.Message);
        }
Exemple #16
0
 public void NonRegexParser()
 {
     MustacheParser.Parse(template);
 }