public void ExcludeModifierOverridesPreviousIncludeModifierTemplateTest() { IEngineEnvironmentSettings environment = TemplateConfigTestHelpers.GetTestEnvironment(); string sourceBasePath = FileSystemHelpers.GetNewVirtualizedPath(environment); TestTemplateSetup setup = SetupXYZFilesForModifierOverrideTestsTemplate(environment, sourceBasePath, ExcludeModifierOverridesPreviousIncludeModifierConfigText); string targetDir = FileSystemHelpers.GetNewVirtualizedPath(environment); IReadOnlyDictionary <string, IReadOnlyList <IFileChange> > allChanges = setup.GetFileChanges(targetDir); Assert.Equal(1, allChanges.Count); if (!allChanges.TryGetValue("./", out IReadOnlyList <IFileChange> changes)) { Assert.True(false, "no changes for source './'"); } Assert.Equal(2, changes.Count); IFileChange includeXyzChangeInfo = changes.FirstOrDefault(x => string.Equals(x.TargetRelativePath, "include.xyz")); Assert.NotNull(includeXyzChangeInfo); Assert.Equal(ChangeKind.Create, includeXyzChangeInfo.ChangeKind); IFileChange otherXyzChangeInfo = changes.FirstOrDefault(x => string.Equals(x.TargetRelativePath, "other.xyz")); Assert.NotNull(otherXyzChangeInfo); Assert.Equal(ChangeKind.Create, otherXyzChangeInfo.ChangeKind); }
public void ExcludeModifierOverridesPreviousIncludeModifierTemplateTest() { string sourceBasePath = FileSystemHelpers.GetNewVirtualizedPath(_engineEnvironmentSettings); SimpleConfigModel config = new SimpleConfigModel() { Identity = "test", Sources = new List <ExtendedFileSource>() { new ExtendedFileSource() { Modifiers = new List <SourceModifier>() { new SourceModifier() { Include = "*.xyz" }, new SourceModifier() { Exclude = "exclude.xyz", }, } } } }; IDictionary <string, string> templateSourceFiles = new Dictionary <string, string>(); templateSourceFiles.Add(TestFileSystemHelper.DefaultConfigRelativePath, config.ToJObject().ToString()); templateSourceFiles.Add("other.xyz", null); templateSourceFiles.Add("include.xyz", null); templateSourceFiles.Add("exclude.xyz", null); TestTemplateSetup setup = new TestTemplateSetup(_engineEnvironmentSettings, sourceBasePath, templateSourceFiles, config); setup.WriteSource(); string targetDir = FileSystemHelpers.GetNewVirtualizedPath(_engineEnvironmentSettings); IReadOnlyDictionary <string, IReadOnlyList <IFileChange2> > allChanges = setup.GetFileChanges(targetDir); Assert.Equal(1, allChanges.Count); if (!allChanges.TryGetValue("./", out IReadOnlyList <IFileChange2> changes)) { Assert.True(false, "no changes for source './'"); } Assert.Equal(2, changes.Count); IFileChange2 includeXyzChangeInfo = changes.FirstOrDefault(x => string.Equals(x.TargetRelativePath, "include.xyz")); Assert.NotNull(includeXyzChangeInfo); Assert.Equal(ChangeKind.Create, includeXyzChangeInfo.ChangeKind); IFileChange2 otherXyzChangeInfo = changes.FirstOrDefault(x => string.Equals(x.TargetRelativePath, "other.xyz")); Assert.NotNull(otherXyzChangeInfo); Assert.Equal(ChangeKind.Create, otherXyzChangeInfo.ChangeKind); }
public void CopyOnlyWithoutIncludeDoesntActuallyCopyFile() { string sourceBasePath = FileSystemHelpers.GetNewVirtualizedPath(_engineEnvironmentSettings); SimpleConfigModel config = new SimpleConfigModel() { Identity = "test", Sources = new List <ExtendedFileSource>() { new ExtendedFileSource() { Include = "**/*.txt", Modifiers = new List <SourceModifier>() { new SourceModifier() { CopyOnly = "copy.me" } } } } }; IDictionary <string, string> templateSourceFiles = new Dictionary <string, string>(); templateSourceFiles.Add(TestFileSystemHelper.DefaultConfigRelativePath, config.ToJObject().ToString()); templateSourceFiles.Add("something.txt", null); templateSourceFiles.Add("copy.me", null); TestTemplateSetup setup = new TestTemplateSetup(_engineEnvironmentSettings, sourceBasePath, templateSourceFiles, config); setup.WriteSource(); string targetDir = FileSystemHelpers.GetNewVirtualizedPath(_engineEnvironmentSettings); IReadOnlyDictionary <string, IReadOnlyList <IFileChange2> > allChanges = setup.GetFileChanges(targetDir); // one source, should cause one set of changes Assert.Equal(1, allChanges.Count); if (!allChanges.TryGetValue("./", out IReadOnlyList <IFileChange2> changes)) { Assert.True(false, "no changes for source './'"); } Assert.Equal(1, changes.Count); Assert.Equal(ChangeKind.Create, changes[0].ChangeKind); Assert.True(string.Equals(changes[0].TargetRelativePath, "something.txt"), "didn't copy the correct file"); }
public void SourceModifierRenameIsCaseSensitive() { IEngineEnvironmentSettings environment = TemplateConfigTestHelpers.GetTestEnvironment(); string sourceBasePath = FileSystemHelpers.GetNewVirtualizedPath(environment); TestTemplateSetup setup = SetupSourceModifierRenameIsCaseSensitiveTestTemplate(environment, sourceBasePath); string targetDir = FileSystemHelpers.GetNewVirtualizedPath(environment); IReadOnlyDictionary <string, IReadOnlyList <IFileChange2> > allChanges = setup.GetFileChanges(targetDir); Assert.Equal(1, allChanges.Count); // one source had changes Assert.True(allChanges.TryGetValue("./", out IReadOnlyList <IFileChange2> changes), "No changes for source './'"); Assert.Equal(2, changes.Count); Assert.Equal(1, changes.Count(x => string.Equals(x.TargetRelativePath, "YesNewName.txt", StringComparison.Ordinal))); Assert.Equal(1, changes.Count(x => string.Equals(x.TargetRelativePath, "dontrenameme.txt", StringComparison.Ordinal))); Assert.Equal(0, changes.Count(x => string.Equals(x.TargetRelativePath, "NoNewName.txt", StringComparison.Ordinal))); }
public void IncludeModifierOverridesPreviousExcludeModifierTemplateTest() { string sourceBasePath = FileSystemHelpers.GetNewVirtualizedPath(_engineEnvironmentSettings); TestTemplateSetup setup = SetupXYZFilesForModifierOverrideTestsTemplate(_engineEnvironmentSettings, sourceBasePath, IncludeModifierOverridesPreviousExcludeModifierConfigText); string targetDir = FileSystemHelpers.GetNewVirtualizedPath(_engineEnvironmentSettings); IReadOnlyDictionary <string, IReadOnlyList <IFileChange2> > allChanges = setup.GetFileChanges(targetDir); Assert.Equal(1, allChanges.Count); if (!allChanges.TryGetValue("./", out IReadOnlyList <IFileChange2> changes)) { Assert.True(false, "no changes for source './'"); } Assert.Equal(1, changes.Count); Assert.Equal(ChangeKind.Create, changes[0].ChangeKind); Assert.True(string.Equals(changes[0].TargetRelativePath, "include.xyz"), "include modifier didn't properly override exclude modifier"); }
public void CopyOnlyWithWildcardAndParentIncludeActuallyCopiesFile() { string sourceBasePath = FileSystemHelpers.GetNewVirtualizedPath(_engineEnvironmentSettings); TestTemplateSetup setup = SetupCopyOnlyWithWildcardAndParentInclude(_engineEnvironmentSettings, sourceBasePath); string targetDir = FileSystemHelpers.GetNewVirtualizedPath(_engineEnvironmentSettings); IReadOnlyDictionary <string, IReadOnlyList <IFileChange2> > allChanges = setup.GetFileChanges(targetDir); Assert.Equal(1, allChanges.Count); if (!allChanges.TryGetValue("./", out IReadOnlyList <IFileChange2> changes)) { Assert.True(false, "no changes for source './'"); } Assert.Equal(1, changes.Count); Assert.Equal(ChangeKind.Create, changes[0].ChangeKind); Assert.True(string.Equals(changes[0].TargetRelativePath, "copy.me"), "didn't copy the correct file"); }
public void CopyOnlyWithoutIncludeDoesntHappen() { IEngineEnvironmentSettings environment = TemplateConfigTestHelpers.GetTestEnvironment(); string sourceBasePath = FileSystemHelpers.GetNewVirtualizedPath(environment); TestTemplateSetup setup = SetupCopyOnlyTemplate(environment, sourceBasePath); string targetDir = FileSystemHelpers.GetNewVirtualizedPath(environment); IReadOnlyDictionary <string, IReadOnlyList <IFileChange> > allChanges = setup.GetFileChanges(targetDir); // one source, should cause one set of changes Assert.Equal(1, allChanges.Count); if (!allChanges.TryGetValue("./", out IReadOnlyList <IFileChange> changes)) { Assert.True(false, "no changes for source './'"); } Assert.Equal(1, changes.Count); Assert.Equal(ChangeKind.Create, changes[0].ChangeKind); Assert.True(string.Equals(changes[0].TargetRelativePath, "something.txt"), "didn't copy the correct file"); }