public void SplitConfigCantReferenceFileOutsideBasePath() { string sourcePath = FileSystemHelpers.GetNewVirtualizedPath(_engineEnvironmentSettings); TestTemplateSetup setup = SetupSplitConfigWithAFileOutsideMountPoint(_engineEnvironmentSettings, sourcePath); IGenerator generator = new RunnableProjectGenerator(); IFileSystemInfo templateConfigFileInfo = setup.InfoForSourceFile(TemplateConfigTestHelpers.DefaultConfigRelativePath); bool result = generator.TryGetTemplateFromConfigInfo(templateConfigFileInfo, out ITemplate template, null, null); Assert.False(result, "Template config should not be readable - additional file is outside the base path."); Assert.Null(template); }
public void SplitConfigReadFailsIfAReferencedFileIsMissing() { string sourcePath = FileSystemHelpers.GetNewVirtualizedPath(_engineEnvironmentSettings); TestTemplateSetup setup = SetupSplitConfigWithAMissingReferencedFile(_engineEnvironmentSettings, sourcePath); IGenerator generator = new RunnableProjectGenerator(); IFileSystemInfo templateConfigFileInfo = setup.InfoForSourceFile(TestFileSystemHelper.DefaultConfigRelativePath); bool result = generator.TryGetTemplateFromConfigInfo(templateConfigFileInfo, out ITemplate template, null, null); Assert.False(result, "Template config should not be readable - missing additional file."); Assert.Null(template); }
public void SplitConfigTest() { string sourcePath = FileSystemHelpers.GetNewVirtualizedPath(_engineEnvironmentSettings); TestTemplateSetup setup = SetupSplitConfigTestTemplate(_engineEnvironmentSettings, sourcePath); IGenerator generator = new RunnableProjectGenerator(); IFileSystemInfo templateConfigFileInfo = setup.InfoForSourceFile("templateSource/.template.config/template.json"); generator.TryGetTemplateFromConfigInfo(templateConfigFileInfo, out ITemplate template, null, null); IDictionary <string, ITemplateParameter> parameters = template.Parameters.ToDictionary(p => p.Name, p => p); Assert.Equal(5, parameters.Count); // 5 in the configs + 1 for 'name' (implicit) Assert.True(parameters.ContainsKey("type")); Assert.True(parameters.ContainsKey("language")); Assert.True(parameters.ContainsKey("RuntimeFrameworkVersion")); Assert.True(parameters.ContainsKey("Framework")); Assert.True(parameters.ContainsKey("MyThing")); }
public void SetConfigTimestampUtc() { string templateJson = @" { ""name"": ""TestTemplate"", ""identity"": ""TestTemplate"", ""shortName"": ""testt"", ""symbols"": { ""mySymbol"": { ""type"": ""parameter"", ""replaces"": ""whatever"", ""forms"": { ""global"": [ ""fakeName"" ], } } } } "; var pathToTemplateJson = "templateSource/.template.config/template.json"; string sourcePath = FileSystemHelpers.GetNewVirtualizedPath(EngineEnvironmentSettings); IDictionary <string, string> templateSourceFiles = new Dictionary <string, string>(); templateSourceFiles.Add(pathToTemplateJson, templateJson); TestTemplateSetup setup = new TestTemplateSetup(EngineEnvironmentSettings, sourcePath, templateSourceFiles); setup.WriteSource(); RunnableProjectGenerator generator = new RunnableProjectGenerator(); var templateFile = setup.InfoForSourceFile(pathToTemplateJson); generator.TryGetTemplateFromConfigInfo(templateFile, out ITemplate template, null, null); var templateWithTimestamp = Assert.IsAssignableFrom <ITemplateWithTimestamp>(template); Assert.NotNull(templateWithTimestamp.ConfigTimestampUtc); }