public void SetUp() { var context = TemplatePlan.CreateClean("assembly-info"); context.Add(new CreateSolution("AssemblyInfoSolution")); var project = new ProjectPlan("MyProject"); context.Add(project); var system = new FileSystem(); system.CreateDirectory("assembly-info"); system.CreateDirectory("assembly-info", "src"); system.CreateDirectory("assembly-info", "src", "MyProject"); system.CreateDirectory("assembly-info", "src", "MyProject", "Properties"); var expectedPath = "assembly-info".AppendPath("src", "MyProject", "Properties", "AssemblyInfo.cs"); system.WriteStringToFile(expectedPath, @"using System.Reflection; [assembly: AssemblyTitle('MyProject')] ".Replace("'", "\"")); var alteration = new AssemblyInfoAlteration("using System.Reflection;", "[assembly: AssemblyTitle(\"%ASSEMBLYNAME%\")]", "using FubuMVC.Core;", "[assembly: FubuModule]"); project.Add(alteration); context.Execute(); theProject = CsProjFile.LoadFrom("assembly-info".AppendPath("src", "MyProject", "MyProject.csproj")); theContents = new FileSystem().ReadStringFromFile(expectedPath); }
public void SetUp() { thePlan = TemplatePlan.CreateClean("copy-references"); thePlan.FileSystem.WriteStringToFile("ripple.dependencies.config", @"FubuCore FubuMVC.Core "); thePlan.Add(new CreateSolution("References")); var originalPlan = new ProjectPlan("References"); thePlan.Add(originalPlan); originalPlan.Add(new SystemReference("System.Data")); originalPlan.Add(new SystemReference("System.Configuration")); originalPlan.Add(new CopyFileToProject("ripple.dependencies.config", "ripple.dependencies.config")); originalPlan.NugetDeclarations.Add("Bottles"); originalPlan.NugetDeclarations.Add("FubuMVC.Core"); originalPlan.NugetDeclarations.Add("FubuLocalization"); testingPlan = new ProjectPlan("References.Testing"); thePlan.Add(testingPlan); thePlan.Add(new CopyProjectReferences("References")); thePlan.Execute(); theOriginalProject = thePlan.Solution.FindProject("References").Project; theTestingProject = thePlan.Solution.FindProject("References.Testing").Project; }
public void SetUp() { thePlan = TemplatePlan.CreateClean("gitignore"); _contents = new Lazy <string[]>(() => { return(fileSystem.ReadStringFromFile("gitignore", ".gitignore").SplitOnNewLine().ToArray()); }); }
public void creates_a_new_directory_if_it_does_not_already_exist() { var solutionDirectory = new SolutionDirectory("foo"); var plan = TemplatePlan.CreateClean("solution"); solutionDirectory.Alter(plan); Directory.Exists("solution".AppendPath("foo")).ShouldBeTrue(); }
public DataMother(string directory, bool withProject = true) { _directory = directory; _plan = TemplatePlan.CreateClean(_directory); if (withProject) { _plan.Add(new ProjectPlan("SomeProject")); } }
public void execute_blows_up_if_there_are_any_missing_inputs() { var plan = TemplatePlan.CreateClean("missing-inputs"); plan.MissingInputs.Add("Foo"); plan.MissingInputs.Add("Bar"); Exception <MissingInputException> .ShouldBeThrownBy(() => { plan.Execute(); }).InputNames.ShouldHaveTheSameElementsAs("Foo", "Bar"); }
public void project_folder_is_substituted() { thePlan = TemplatePlan.CreateClean("create-solutionProject"); thePlan.Add(new CreateSolution("MySolution")); thePlan.Add(new ProjectPlan("MyProject")); thePlan.Execute(); thePlan.CurrentProject.ApplySubstitutions("*%PROJECT_FOLDER%*") .ShouldEqual("*src/MyProject*"); }
public void create_a_deep_directory() { var solutionDirectory = new SolutionDirectory("foo/bar"); var plan = TemplatePlan.CreateClean("solution"); solutionDirectory.Alter(plan); Directory.Exists("solution".AppendPath("foo")).ShouldBeTrue(); Directory.Exists("solution".AppendPath("foo", "bar")).ShouldBeTrue(); }
public void does_not_cause_any_problems_when_the_directory_already_exists() { var solutionDirectory = new SolutionDirectory("foo"); var plan = TemplatePlan.CreateClean("solution"); Directory.CreateDirectory("solution".AppendPath("foo")); solutionDirectory.Alter(plan); Directory.Exists("solution".AppendPath("foo")).ShouldBeTrue(); }
public void write_gem_file_when_none_exists() { var context = TemplatePlan.CreateClean("gems"); var gem = new GemReference("rake", ">=10.0.3"); gem.Alter(context); var gemFile = "gems".AppendPath("Gemfile"); var contents = new FileSystem().ReadStringFromFile(gemFile) .SplitOnNewLine(); contents.ShouldContain("source 'http://rubygems.org'"); contents.ShouldContain("gem \"rake\", \">=10.0.3\""); }
public void copy_a_file() { var context = TemplatePlan.CreateClean("copying"); var file = "foo.txt"; new FileSystem().WriteStringToFile(file, "foo"); var step = new CopyFileToSolution("foo.txt", file); step.Alter(context); File.Exists("copying".AppendPath(file)).ShouldBeTrue(); }
public void reads_existing_solution_and_places_on_the_plan() { var plan = TemplatePlan.CreateClean("create-solution"); var original = Solution.CreateNew("create-solution", "MySln"); original.Save(); var step = new ReadSolution(original.Filename); step.Alter(plan); plan.Solution.ShouldNotBeNull(); plan.Solution.Filename.ShouldEqual(original.Filename); plan.Solution.Name.ShouldEqual("MySln"); }
public void alter_by_creating_new_project_from_default_template() { thePlan = TemplatePlan.CreateClean("create-solutionProject"); thePlan.Add(new CreateSolution("MySolution")); thePlan.Add(new ProjectPlan("MyProject")); thePlan.Execute(); var file = thePlan.SourceDirectory.AppendPath("MyProject", "MyProject.csproj"); File.Exists(file).ShouldBeTrue(); var project = CsProjFile.LoadFrom(file); project.ShouldNotBeNull(); // really just a smoke test }
public void create_a_new_solution() { var context = TemplatePlan.CreateClean("create-solution"); var step = new CreateSolution("MySolution"); context.Add(step); context.Execute(); var file = context.Root.AppendPath("src", "MySolution.sln"); File.Exists(file).ShouldBeTrue(); var solution = Solution.LoadFrom(file); solution.ShouldNotBeNull(); // really just a smoke test that we can parse it back out }
public void adds_the_project_file_to_the_csproj_file_as_Content() { thePlan = TemplatePlan.CreateClean("copy-file-to-project"); thePlan.Add(new CreateSolution("MySolution")); var projectPlan = new ProjectPlan("MyProject"); thePlan.Add(projectPlan); thePlan.FileSystem.WriteStringToFile("foo.txt", "some text"); projectPlan.Add(new CopyFileToProject("foo.txt", "foo.txt")); thePlan.Execute(); var project = CsProjFile.LoadFrom("copy-file-to-project".AppendPath("src", "MyProject", "MyProject.csproj")); project.Find <Content>("foo.txt").ShouldNotBeNull(); }
public void project_plan_applies_the_dot_net_version() { thePlan = TemplatePlan.CreateClean("create-solutionProject"); thePlan.Add(new CreateSolution("MySolution")); var projectPlan = new ProjectPlan("MyProject"); thePlan.Add(projectPlan); thePlan.Execute(); var file = thePlan.SourceDirectory.AppendPath("MyProject", "MyProject.csproj"); File.Exists(file).ShouldBeTrue(); var project = CsProjFile.LoadFrom(file); project.DotNetVersion.ShouldEqual(DotNetVersion.V40); }
public void copy_a_deep_path_to_the_right_spot() { thePlan = TemplatePlan.CreateClean("copy-file-to-project"); thePlan.Add(new CreateSolution("MySolution")); var projectPlan = new ProjectPlan("MyProject"); thePlan.Add(projectPlan); thePlan.FileSystem.WriteStringToFile("foo.txt", "some text"); projectPlan.Add(new CopyFileToProject("bar/folder/foo.txt", "foo.txt")); thePlan.Execute(); var file = FileSystem.Combine(thePlan.SourceDirectory, "MyProject", "bar", "folder", "foo.txt"); File.Exists(file).ShouldBeTrue(); }
public void applies_substitutions() { thePlan = TemplatePlan.CreateClean("copy-file-to-project"); thePlan.Add(new CreateSolution("MySolution")); var projectPlan = new ProjectPlan("MyProject"); thePlan.Add(projectPlan); projectPlan.Substitutions.Set("%TEAM%", "Chiefs"); thePlan.FileSystem.WriteStringToFile("foo.txt", "*%TEAM%*"); projectPlan.Add(new CopyFileToProject("foo.txt", "foo.txt")); thePlan.Execute(); var file = FileSystem.Combine(thePlan.SourceDirectory, "MyProject", "foo.txt"); thePlan.FileSystem.ReadStringFromFile(file).ShouldEqual("*Chiefs*"); }
public void can_write_assembly_reference_to_a_project() { var theContext = TemplatePlan.CreateClean("assembly-ref"); theContext.Add(new CreateSolution("MySolution")); var projectPlan = new ProjectPlan("MyProject"); theContext.Add(projectPlan); projectPlan.Add(new SystemReference("System.Configuration")); theContext.Execute(); var project = CsProjFile.LoadFrom("assembly-ref".AppendPath("src", "MyProject", "MyProject.csproj")); project.Find <AssemblyReference>("System.Configuration") .ShouldNotBeNull(); }
public void do_add_gem_to_existing() { var gemFile = "gems".AppendPath("Gemfile"); new FileSystem().WriteStringToFile(gemFile, @"source 'http://rubygems.org' gem ~rake~, ~>=10.0.3~ ".Replace("~", "\"")); var context = TemplatePlan.CreateClean("gems"); var gem = new GemReference("fuburake", "~>0.5"); gem.Alter(context); var contents = new FileSystem().ReadStringFromFile(gemFile) .SplitOnNewLine(); contents.ShouldContain("source 'http://rubygems.org'"); contents.ShouldContain("gem \"fuburake\", \"~>0.5\""); // didn't change }
public void alter_by_creating_a_new_project_with_a_project_template_file() { thePlan = TemplatePlan.CreateClean("create-solutionProject"); thePlan.Add(new CreateSolution("MySolution")); thePlan.Add(new ProjectPlan("MyProject") { ProjectTemplateFile = "Project.txt" }); thePlan.Execute(); var file = thePlan.SourceDirectory.AppendPath("MyProject", "MyProject.csproj"); File.Exists(file).ShouldBeTrue(); var project = CsProjFile.LoadFrom(file); project.All <AssemblyReference>().Any(x => x.Include == "System.Data") .ShouldBeTrue(); // the 'special' testing template has this reference, but the default template does not }
public void write_out_nuget_imports() { var plan = TemplatePlan.CreateClean("nuget-imports"); plan.Add(new ProjectPlan("MyProject1")); plan.CurrentProject.NugetDeclarations.Add("FubuCore"); plan.CurrentProject.NugetDeclarations.Add("FubuMVC.Core"); plan.CurrentProject.NugetDeclarations.Add("RavenDb/2.0.0.0"); plan.Add(new ProjectPlan("MyProject2")); plan.CurrentProject.NugetDeclarations.Add("RavenDb/2.0.0.0"); plan.WriteNugetImports(); TemplateLibrary.FileSystem.ReadStringFromFile("nuget-imports".AppendPath(TemplatePlan.RippleImportFile)) .ReadLines().ShouldHaveTheSameElementsAs( "MyProject1: FubuCore, FubuMVC.Core, RavenDb/2.0.0.0", "MyProject2: RavenDb/2.0.0.0" ); }
public void copy_a_file_applies_substitutions() { var context = TemplatePlan.CreateClean("copying"); context.Solution = Solution.CreateNew("copying".AppendPath("src"), "FooSolution"); var file = "foo.txt"; new FileSystem().WriteStringToFile(file, "*%SOLUTION_NAME%*"); var step = new CopyFileToSolution("foo.txt", file); step.Alter(context); var expectedFile = "copying".AppendPath(file); File.Exists(expectedFile).ShouldBeTrue(); new FileSystem().ReadStringFromFile(expectedFile) .ShouldEqual("*FooSolution*"); }
public void do_not_add_gem_when_there_is_already_a_reference() { var gemFile = "gems".AppendPath("Gemfile"); var context = TemplatePlan.CreateClean("gems"); new FileSystem().WriteStringToFile(gemFile, @"source 'http://rubygems.org' gem ~rake~, ~>=10.0.3~ ".Replace("~", "\"")); var gem = new GemReference("rake", ">=10.0.4"); gem.Alter(context); var contents = new FileSystem().ReadStringFromFile(gemFile) .SplitOnNewLine(); contents.ShouldContain("source 'http://rubygems.org'"); contents.ShouldContain("gem \"rake\", \">=10.0.3\""); // didn't change contents.ShouldNotContain("gem \"rake\", \">=10.0.4\""); // didn't change }
public void SetUp() { plan = TemplatePlan.CreateClean("rake"); rakefilePath = "rake".AppendPath("rakefile"); }