Exemple #1
0
        public void ExcludeModifierOverridesPreviousIncludeModifierTemplateTest()
        {
            IEngineEnvironmentSettings environment = TemplateConfigTestHelpers.GetTestEnvironment();
            string sourceBasePath = TemplateConfigTestHelpers.GetNewVirtualizedPath(environment);

            TestTemplateSetup setup     = SetupXYZFilesForModifierOverrideTestsTemplate(environment, sourceBasePath, ExcludeModifierOverridesPreviousIncludeModifierConfigText);
            string            targetDir = TemplateConfigTestHelpers.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 SplitConfigReadFailsIfAReferencedFileIsMissing()
        {
            string            sourcePath = TemplateConfigTestHelpers.GetNewVirtualizedPath(EngineEnvironmentSettings);
            TestTemplateSetup setup      = SetupSplitConfigWithAMissingReferencedFile(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 - missing additional file.");
            Assert.Null(template);
        }
Exemple #3
0
        public void SourceConfigExcludesAreOverriddenByIncludes()
        {
            IEngineEnvironmentSettings environment = TemplateConfigTestHelpers.GetTestEnvironment();
            string sourceBasePath = TemplateConfigTestHelpers.GetNewVirtualizedPath(environment);

            TestTemplateSetup setup     = SetupTwoFilesWithConfigExtensionTemplate(environment, sourceBasePath);
            string            targetDir = TemplateConfigTestHelpers.GetNewVirtualizedPath(environment);

            setup.InstantiateTemplate(targetDir);

            Assert.True(environment.Host.FileSystem.FileExists(Path.Combine(targetDir, "core.config")));
            Assert.False(environment.Host.FileSystem.FileExists(Path.Combine(targetDir, "full.config")));
        }
        public void SplitConfigTest()
        {
            string            sourcePath = TemplateConfigTestHelpers.GetNewVirtualizedPath(EngineEnvironmentSettings);
            TestTemplateSetup setup      = SetupSplitConfigTestTemplate(EngineEnvironmentSettings, sourcePath);

            IGenerator      generator = new RunnableProjectGenerator();
            IFileSystemInfo templateConfigFileInfo = setup.InfoForSourceFile(TemplateConfigTestHelpers.DefaultConfigRelativePath);

            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);
            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"));
        }
Exemple #5
0
        public void IncludeModifierOverridesPreviousExcludeModifierTemplateTest()
        {
            IEngineEnvironmentSettings environment = TemplateConfigTestHelpers.GetTestEnvironment();
            string sourceBasePath = TemplateConfigTestHelpers.GetNewVirtualizedPath(environment);

            TestTemplateSetup setup     = SetupXYZFilesForModifierOverrideTestsTemplate(environment, sourceBasePath, IncludeModifierOverridesPreviousExcludeModifierConfigText);
            string            targetDir = TemplateConfigTestHelpers.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(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");
        }
Exemple #6
0
        public void CopyOnlyWithoutIncludeDoesntHappen()
        {
            IEngineEnvironmentSettings environment = TemplateConfigTestHelpers.GetTestEnvironment();
            string sourceBasePath = TemplateConfigTestHelpers.GetNewVirtualizedPath(environment);

            TestTemplateSetup setup     = SetupCopyOnlyTemplate(environment, sourceBasePath);
            string            targetDir = TemplateConfigTestHelpers.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");
        }