Ejemplo n.º 1
0
        public void ShouldAddExpectedFeatureName_TheNamespaceClosestToTheController2()
        {
            var fc    = new FeatureConvention();
            var model = new ControllerModel(typeof(Features.Controller1).GetTypeInfo(), new List <object>())
            {
                ControllerName = "Controller1"
            };

            fc.Apply(model);

            model.Properties.Should().ContainKey("feature");
            model.Properties["feature"].Should().IsSameOrEqualTo("Features");
        }
Ejemplo n.º 2
0
        public void ShouldAddFeatureAsAnEmptyStringForControllersFoundWithoutAClearReference()
        {
            var fc    = new FeatureConvention();
            var model = new ControllerModel(typeof(Mvc.Controller1).GetTypeInfo(), new List <object>())
            {
                ControllerName = "Controller1"
            };

            fc.Apply(model);

            model.Properties.Should().ContainKey("feature");
            model.Properties["feature"].Should().IsSameOrEqualTo(string.Empty);
        }
Ejemplo n.º 3
0
        public void ShouldDeleteScriptFile()
        {
            const string deployStage = "BeforeDeploy";
            const string feature     = "doTheThing";
            var          scriptPath  = Path.Combine(stagingDirectory, FeatureConvention.GetScriptName(feature, deployStage, "ps1"));

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

            scriptEngine.Execute(Arg.Is <Script>(s => s.File == scriptPath), variables, commandLineRunner).Returns(new CommandResult("", 0));
            convention.Install(deployment);
            fileSystem.Received().DeleteFile(scriptPath, Arg.Any <FailureOptions>());
        }
Ejemplo n.º 4
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)
            {
                var scriptPath = Path.Combine(stagingDirectory, FeatureConvention.GetScriptName(feature, suffix, "ps1"));
                scriptEngine.Received().Execute(Arg.Is <Script>(s => s.File == scriptPath), variables, commandLineRunner);
            }
        }
Ejemplo n.º 5
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           = FeatureConvention.GetScriptName(feature, suffix, "ps1");
                var embeddedResourceName = FeatureConvention.GetEmbeddedResourceName(scriptName);
                embeddedResources.GetEmbeddedResourceText(Arg.Any <Assembly>(), embeddedResourceName).Returns(scriptContents);
                embeddedResourceNames.Add(embeddedResourceName);
                var scriptPath = Path.Combine(stagingDirectory, scriptName);
                scriptEngine.Execute(Arg.Is <Script>(s => s.File == scriptPath), variables, commandLineRunner)
                .Returns(new CommandResult("", 0));
            }

            embeddedResources.GetEmbeddedResourceNames(Arg.Any <Assembly>()).Returns(embeddedResourceNames.ToArray());
        }
Ejemplo n.º 6
0
        public void ShouldCreateScriptFileIfNotExists()
        {
            const string deployStage = "BeforePostDeploy";
            const string feature     = "doTheThing";
            var          scriptPath  = Path.Combine(stagingDirectory, FeatureConvention.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(Arg.Is <Script>(s => s.File == scriptPath), variables, commandLineRunner).Returns(new CommandResult("", 0));
            convention.Install(deployment);

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