public void CheckTemplateSourcesRelativeToTemplateRootMultipleDirsUnderMountPoint(bool shouldAllPathsBeValid, string source) { const string pathFromMountPointRootToTemplateRoot = "MountRoot/Stuff/TemplateRoot/"; string pathToTemplateConfig = pathFromMountPointRootToTemplateRoot + ".template.config/template.json"; string sourcePath = FileSystemHelpers.GetNewVirtualizedPath(EngineEnvironmentSettings); IDictionary <string, string> templateSourceFiles = new Dictionary <string, string>(); string templateConfig = String.Format(TemplateConfigWithSourcePlaceholder, source); templateSourceFiles.Add(pathToTemplateConfig, templateConfig); string sampleContentDir = pathFromMountPointRootToTemplateRoot + "things/stuff/_._"; templateSourceFiles.Add(sampleContentDir, ""); // directories under the template root - valid source locations. templateSourceFiles.Add("ExistingDir/_._", ""); templateSourceFiles.Add("MountRoot/Subdir/_._", ""); TestTemplateSetup setup = new TestTemplateSetup(EngineEnvironmentSettings, sourcePath, templateSourceFiles); setup.WriteSource(); RunnableProjectGenerator generator = new RunnableProjectGenerator(); IFile templateFile = setup.FileInfoForSourceFile(pathToTemplateConfig); JObject srcObject = generator.ReadJObjectFromIFile(templateFile); SimpleConfigModel templateModel = SimpleConfigModel.FromJObject(templateFile.MountPoint.EnvironmentSettings, srcObject); RunnableProjectTemplate runnableProjectTemplate = new RunnableProjectTemplate(srcObject, generator, templateFile, templateModel, null, null); bool allPathsAreValid = generator.AreAllTemplatePathsValid(templateModel, runnableProjectTemplate); Assert.Equal(shouldAllPathsBeValid, allPathsAreValid); }
public void CheckTemplateRootRelativeToInstallPath(string pathToTemplateJson, bool shouldAllPathsBeValid) { SimpleConfigModel baseConfig = SimpleConfigModel.FromJObject(JObject.Parse(BasicTemplateConfig)); RunnableProjectGenerator generator = new RunnableProjectGenerator(); string sourcePath = FileSystemHelpers.GetNewVirtualizedPath(_engineEnvironmentSettings); IDictionary <string, string> templateSourceFiles = new Dictionary <string, string>(); templateSourceFiles.Add(pathToTemplateJson, BasicTemplateConfig); TestTemplateSetup setup = new TestTemplateSetup(_engineEnvironmentSettings, sourcePath, templateSourceFiles); setup.WriteSource(); IFile templateFile = setup.FileInfoForSourceFile(pathToTemplateJson); RunnableProjectConfig templateModel = new RunnableProjectConfig(_engineEnvironmentSettings, generator, baseConfig, templateFile); if (shouldAllPathsBeValid) { Assert.Empty(templateModel.ValidateTemplateSourcePaths()); } else { Assert.NotEmpty(templateModel.ValidateTemplateSourcePaths()); } }
public void CheckTemplateSourcesRelativeToTemplateRootMultipleDirsUnderMountPoint(bool shouldAllPathsBeValid, string source) { string templateConfig = string.Format(TemplateConfigWithSourcePlaceholder, source); SimpleConfigModel baseConfig = SimpleConfigModel.FromJObject(JObject.Parse(templateConfig)); RunnableProjectGenerator generator = new RunnableProjectGenerator(); const string pathFromMountPointRootToTemplateRoot = "MountRoot/Stuff/TemplateRoot/"; string pathToTemplateConfig = pathFromMountPointRootToTemplateRoot + ".template.config/template.json"; string sourcePath = FileSystemHelpers.GetNewVirtualizedPath(_engineEnvironmentSettings); IDictionary <string, string> templateSourceFiles = new Dictionary <string, string>(); templateSourceFiles.Add(pathToTemplateConfig, templateConfig); string sampleContentDir = pathFromMountPointRootToTemplateRoot + "things/stuff/_._"; templateSourceFiles.Add(sampleContentDir, ""); // directories under the template root - valid source locations. templateSourceFiles.Add("ExistingDir/_._", ""); templateSourceFiles.Add("MountRoot/Subdir/_._", ""); TestTemplateSetup setup = new TestTemplateSetup(_engineEnvironmentSettings, sourcePath, templateSourceFiles); setup.WriteSource(); IFile templateFile = setup.FileInfoForSourceFile(pathToTemplateConfig); RunnableProjectConfig templateModel = new RunnableProjectConfig(_engineEnvironmentSettings, generator, baseConfig, templateFile); if (shouldAllPathsBeValid) { Assert.Empty(templateModel.ValidateTemplateSourcePaths()); } else { Assert.NotEmpty(templateModel.ValidateTemplateSourcePaths()); } }
public void CheckTemplateRootRelativeToInstallPath(string pathToTemplateJson, bool shouldAllPathsBeValid) { string sourcePath = FileSystemHelpers.GetNewVirtualizedPath(EngineEnvironmentSettings); IDictionary <string, string> templateSourceFiles = new Dictionary <string, string>(); templateSourceFiles.Add(pathToTemplateJson, BasicTemplateConfig); TestTemplateSetup setup = new TestTemplateSetup(EngineEnvironmentSettings, sourcePath, templateSourceFiles); setup.WriteSource(); RunnableProjectGenerator generator = new RunnableProjectGenerator(); IFile templateFile = setup.FileInfoForSourceFile(pathToTemplateJson); JObject srcObject = generator.ReadJObjectFromIFile(templateFile); SimpleConfigModel templateModel = SimpleConfigModel.FromJObject(templateFile.MountPoint.EnvironmentSettings, srcObject); RunnableProjectTemplate runnableProjectTemplate = new RunnableProjectTemplate(srcObject, generator, templateFile, templateModel, null, null); bool allPathsAreValid = generator.AreAllTemplatePathsValid(templateModel, runnableProjectTemplate); Assert.Equal(shouldAllPathsBeValid, allPathsAreValid); }