Exemple #1
0
        public async Task CalamariFlavourProgram_PerformsReplacementCorrectlyWithoutCanonicalFileExtension(string configFileName, string variableName, string expectedReplacer)
        {
            const string newPort = "4444";

            using (var tempPath = TemporaryDirectory.Create())
            {
                var targetPath = Path.Combine(tempPath.DirectoryPath, configFileName);
                File.Copy(BuildConfigPath(configFileName), targetPath);

                await CommandTestBuilder.Create <NoOpTraditionalCommandWithStructuredVariableReplacementConvention, SyncFlavourProgram>()
                .WithArrange(context =>
                {
                    context.Variables.Add(KnownVariables.Package.EnabledFeatures, KnownVariables.Features.StructuredConfigurationVariables);
                    context.Variables.Add(ActionVariables.StructuredConfigurationVariablesTargets, configFileName);
                    context.Variables.Add(variableName, newPort);
                    context.WithFilesToCopy(tempPath.DirectoryPath);
                })
                .WithAssert(result =>
                {
                    //result.FullLog.Should().Contain($"Structured variable replacement succeeded on file {targetPath} with format {expectedReplacer}");
                    File.ReadAllText(targetPath).Should().Contain(newPort);
                })
                .Execute();
            }
        }