Exemple #1
0
        public void ShouldDeleteScriptFile()
        {
            const string deployStage = "BeforeDeploy";
            const string feature     = "doTheThing";
            var          scriptPath  = Path.Combine(stagingDirectory, FeatureScriptConvention.GetScriptName(feature, deployStage, "ps1"));

            Arrange(new List <string> {
                feature
            }, deployStage);
            var convention = CreateConvention(deployStage);

            scriptEngine.Execute(scriptPath, variables, commandLineRunner).Returns(new CommandResult("", 0));
            convention.Install(deployment);
            fileSystem.Received().DeleteFile(scriptPath, Arg.Any <FailureOptions>());
        }
Exemple #2
0
        public void ShouldRunMatchingScripts()
        {
            const string suffix   = "AfterPreDeploy";
            var          features = new string[] { "feature1", "feature2" };

            Arrange(features, suffix);

            var convention = CreateConvention(suffix);

            convention.Install(deployment);

            foreach (var feature in features)
            {
                scriptEngine.Received().Execute(Path.Combine(stagingDirectory, FeatureScriptConvention.GetScriptName(feature, suffix, "ps1")), variables, commandLineRunner);
            }
        }
Exemple #3
0
        private void Arrange(ICollection <string> features, string suffix)
        {
            variables.Set(SpecialVariables.Package.EnabledFeatures, string.Join(",", features));

            var embeddedResourceNames = new List <string>();

            foreach (var feature in features)
            {
                var scriptName           = FeatureScriptConvention.GetScriptName(feature, suffix, "ps1");
                var embeddedResourceName = FeatureScriptConvention.GetEmbeddedResourceName(scriptName);
                embeddedResources.GetEmbeddedResourceText(embeddedResourceName).Returns(scriptContents);
                embeddedResourceNames.Add(embeddedResourceName);
                var scriptPath = Path.Combine(stagingDirectory, scriptName);
                scriptEngine.Execute(scriptPath, variables, commandLineRunner).Returns(new CommandResult("", 0));
            }

            embeddedResources.GetEmbeddedResourceNames().Returns(embeddedResourceNames.ToArray());
        }
        public void ShouldNotOverwriteScriptFileIfItExists()
        {
            const string deployStage = "BeforeDeploy";
            const string feature     = "doTheThing";
            var          scriptPath  = Path.Combine(stagingDirectory, FeatureScriptConvention.GetScriptName(feature, deployStage, "ps1"));

            Arrange(new List <string> {
                feature
            }, deployStage);
            fileSystem.FileExists(scriptPath).Returns(true);

            var convention = CreateConvention(deployStage);

            scriptEngine.Execute(Arg.Is <Script>(s => s.File == scriptPath), variables, commandLineRunner).Returns(new CommandResult("", 0));
            convention.Install(deployment);

            fileSystem.DidNotReceive().OverwriteFile(scriptPath, Arg.Any <string>());
        }
Exemple #5
0
        public void ShouldCreateScriptFileIfNotExists()
        {
            const string deployStage = "BeforePostDeploy";
            const string feature     = "doTheThing";
            var          scriptPath  = Path.Combine(stagingDirectory, FeatureScriptConvention.GetScriptName(feature, deployStage, "ps1"));

            variables.Set(SpecialVariables.Package.EnabledFeatures, feature);

            Arrange(new List <string> {
                feature
            }, deployStage);
            fileSystem.FileExists(scriptPath).Returns(false);

            var convention = CreateConvention(deployStage);

            scriptEngine.Execute(scriptPath, variables, commandLineRunner).Returns(new CommandResult("", 0));
            convention.Install(deployment);

            fileSystem.Received().OverwriteFile(scriptPath, scriptContents);
        }