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 create_solution_add_project_save_and_reload_2() { // Yeah, this is a big bang test. Just go with it. var solution = Solution.CreateNew("TestSolution", "Lib1.TestSolution"); var reference = solution.AddProject("TestProject"); reference.ProjectGuid.ShouldNotEqual(Guid.Empty); reference.ProjectName.ShouldEqual("TestProject"); reference.RelativePath.ShouldEqual("TestProject".AppendPath("TestProject.csproj")); var plan = new ProjectPlan(reference.ProjectName); CodeFileTemplate.Class("Foo").Alter(reference.Project, plan); CodeFileTemplate.Class("Bar").Alter(reference.Project, plan); solution.Save(); File.Exists("TestSolution".AppendPath("Lib1.TestSolution.sln")).ShouldBeTrue(); File.Exists("TestSolution".AppendPath("TestProject", "TestProject.csproj")).ShouldBeTrue(); var solution2 = Solution.LoadFrom("TestSolution".AppendPath("Lib1.TestSolution.sln")); var reference2 = solution2.FindProject("TestProject"); reference2.ShouldNotBeNull(); var project2 = reference2.Project; project2.ShouldNotBeNull(); project2.All<CodeFile>().OrderBy(x => x.Include) .Select(x => x.Include) .ShouldHaveTheSameElementsAs("Bar.cs", "Foo.cs"); }
public void Alter(List <string> contents, ProjectPlan plan) { _additions .Select(x => plan.ApplySubstitutions(x)) .Where(x => !contents.Contains(x)) .Each(contents.Add); }
public void Alter(List<string> contents, ProjectPlan plan) { _additions .Select(x => plan.ApplySubstitutions(x)) .Where(x => !contents.Contains(x)) .Each(contents.Add); }
private static void copyNugetDeclarations(ProjectPlan originalPlan, ProjectPlan testPlan, CsProjFile original, CsProjFile testProject) { originalPlan.NugetDeclarations.Each(x => testPlan.NugetDeclarations.Fill(x)); original.All <AssemblyReference>() .Where(x => x.HintPath.IsEmpty()) .Each(x => testProject.Add <AssemblyReference>(x.Include)); }
private void findNugetsInOriginalRippleDeclarations(TemplatePlan plan, ProjectPlan testPlan) { var configFile = _originalProject.ParentDirectory().AppendPath("ripple.dependencies.config"); plan.FileSystem.ReadTextFile(configFile, line => { if (line.IsNotEmpty()) { testPlan.NugetDeclarations.Fill(line); } }); }
public void Alter(CsProjFile file, ProjectPlan plan) { var fileSystem = new FileSystem(); var rawText = fileSystem.ReadStringFromFile(_source); var templatedText = plan. ApplySubstitutions(rawText, _relativePath); var expectedPath = file.ProjectDirectory.AppendPath(_relativePath); fileSystem.WriteStringToFile(expectedPath, templatedText); }
public void Alter(CsProjFile file, ProjectPlan plan) { var codeFile = file.Find<CodeFile>(AssemblyInfoPath) ?? file.Add<CodeFile>(AssemblyInfoPath); var path = file.PathTo(codeFile); var parentDirectory = path.ParentDirectory(); if (!Directory.Exists(parentDirectory)) { Directory.CreateDirectory(parentDirectory); } new FileSystem().AlterFlatFile(path, contents => Alter(contents, plan)); }
public void Alter(CsProjFile file, ProjectPlan plan) { var fileSystem = new FileSystem(); var rawText = fileSystem.ReadStringFromFile(_source); var templatedText = plan. ApplySubstitutions(rawText, _relativePath); var expectedPath = file.ProjectDirectory.AppendPath(_relativePath); fileSystem.WriteStringToFile(expectedPath, templatedText); file.Add(new Content(_relativePath)); }
public void Alter(CsProjFile file, ProjectPlan plan) { var assemblyInfoPath = Path.Combine(AssemblyInfoPath); var codeFile = file.Find <CodeFile>(assemblyInfoPath) ?? file.Add <CodeFile>(assemblyInfoPath); var path = file.PathTo(codeFile); var parentDirectory = path.ParentDirectory(); if (!Directory.Exists(parentDirectory)) { Directory.CreateDirectory(parentDirectory); } new FileSystem().AlterFlatFile(path, contents => Alter(contents, plan)); }
public void Alter(CsProjFile file, ProjectPlan plan) { var includePath = plan.ApplySubstitutions(_relativePath); var filename = file.FileName.ParentDirectory().AppendPath(includePath); if (!filename.EndsWith(".cs")) { filename = filename + ".cs"; } var text = plan.ApplySubstitutions(_rawText, _relativePath); new FileSystem().WriteStringToFile(filename, text); file.Add<CodeFile>(includePath); }
public void Alter(CsProjFile file, ProjectPlan plan) { var includePath = plan.ApplySubstitutions(_relativePath); var filename = file.FileName.ParentDirectory().AppendPath(includePath); if (!filename.EndsWith(".cs")) { filename = filename + ".cs"; } var text = plan.ApplySubstitutions(_rawText, _relativePath); new FileSystem().WriteStringToFile(filename, text); file.Add <CodeFile>(includePath); }
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 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 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 SetUp() { var context = TemplatePlan.CreateClean("assembly-info"); context.Add(new CreateSolution("AssemblyInfoSolution")); var project = new ProjectPlan("MyProject"); context.Add(project); var alteration = new AssemblyInfoAlteration("using System.Reflection;", "[assembly: AssemblyTitle(\"%ASSEMBLY_NAME%\")]", "using FubuMVC.Core;", "[assembly: FubuModule]"); project.Add(alteration); context.Execute(); theProject = CsProjFile.LoadFrom("assembly-info".AppendPath("src", "MyProject", "MyProject.csproj")); theContents = new FileSystem().ReadStringFromFile("assembly-info".AppendPath("src", "MyProject", "Properties", "AssemblyInfo.cs")); }
public void Alter(CsProjFile file, ProjectPlan plan) { TemplateLibrary.FileSystem.CreateDirectory(file.ProjectDirectory.AppendPath(_relativePath)); }
public void StartProject(ProjectPlan project) { _currentProject = project; }
private void buildProjectPlan(TemplatePlan plan, ProjectRequest proj) { var projectPlan = new ProjectPlan(proj.Name) {DotNetVersion = proj.Version ?? DotNetVersion.V40}; plan.Add(projectPlan); proj.Substitutions.CopyTo(projectPlan.Substitutions); var planner = new ProjectPlanner(); if (proj.Template.IsNotEmpty()) { planner.CreatePlan(_library.Find(TemplateType.Project, proj.Template), plan); } _library.Find(TemplateType.Alteration, proj.Alterations) .Each(template => planner.CreatePlan(template, plan)); }
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 Alter(CsProjFile file, ProjectPlan plan) { file.Add<AssemblyReference>(_assemblyName); }
public void Alter(CsProjFile file, ProjectPlan plan) { file.Add <AssemblyReference>(_assemblyName); }
public void project_plan_applies_the_dot_net_version_2() { thePlan = TemplatePlan.CreateClean("create-solutionProject"); thePlan.Add(new CreateSolution("MySolution")); var projectPlan = new ProjectPlan("MyProject"); projectPlan.DotNetVersion = DotNetVersion.V45; 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.V45); }
public void SetUp() { new FileSystem().DeleteDirectory("Templated"); new FileSystem().CreateDirectory("Templated"); theProject = CsProjFile.CreateAtSolutionDirectory("TemplatedProject", "Templated"); thePlan = new ProjectPlan(theProject.ProjectName); }
public void Alter(CsProjFile file, ProjectPlan plan) { TemplateLibrary.FileSystem.CreateDirectory(file.ProjectDirectory.AppendPath(_relativePath)); }