Beispiel #1
0
        public void Should_replace_subfiles_in_template(string environment, string setting)
        {
            _settingsSubstitutor = new SettingsSubstitutor(environment);

            //Arrange
            var settings = new Dictionary <string, string[]>
            {
                { "StandardSetting1", new [] { "AAA" } },
                { "StandardSetting2", new [] { "BBB" } },
                { "SubFileFileName", new [] { "Tests.ExampleTemplates.Subfile." + setting + ".template" } }
            };

            // Only add the 3rd setting when testing environment2 - this demonstrates that missing settings don't matter
            // when doing sub-template substitutions as only the sub-templates for the current environment are handled.
            if (environment.Equals("environment2", StringComparison.OrdinalIgnoreCase))
            {
                settings.Add("StandardSetting3", new [] { "CCC" });
            }

            //Act
            _settingsSubstitutor.CreateSubstitutedDirectory(_templatesFolder, _outputFolder, settings);

            //Assert
            var fullEnvironmentFilename = Path.Combine(_outputFolder, environment, "Tests.ExampleTemplates.TemplateWithSubfile.txt");
            var subsituted = Id.PowershellExtensions.Helpers.GetFileWithEncoding(fullEnvironmentFilename);

            Assert.That(subsituted.Contents, Is.StringContaining("StandardSetting2"));
            Assert.That(subsituted.Contents, Is.StringContaining("BBB"));

            var outputDir = Path.Combine(_outputFolder, environment);
            var templates = Directory.GetFiles(outputDir, "*.template");

            Assert.That(templates.Length, Is.EqualTo(0));
        }
 public void SetUp()
 {
     _outputFolder        = GetTempFolderName();
     _settingsSubstitutor = new SettingsSubstitutor();
 }