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); }
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); }
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]); } }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
public void Static_MustacheParser_Throws_On_Null() { Assert.Throws <ArgumentNullException>(() => MustacheParser.Parse(null)); }
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); }
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); }
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); }
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); }
public void NonRegexParser() { MustacheParser.Parse(template); }