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"); }
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); }
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>()); }
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); } }
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()); }
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); }