Example #1
0
        public void add_code_files()
        {
            fileSystem.WriteStringToFile("myproj".AppendPath("foo.cs"), "using System.Web;");
            fileSystem.WriteStringToFile("myproj".AppendPath("bar.cs"), "using System.Web;");

            var project = CsProjFile.CreateAtSolutionDirectory("MyProj", "myproj");

            project.Add <CodeFile>("foo.cs");
            project.Add <CodeFile>("bar.cs");

            project.Save();

            var project2 = CsProjFile.LoadFrom(project.FileName);

            project2.All <CodeFile>().Select(x => x.Include)
            .ShouldHaveTheSameElementsAs("bar.cs", "foo.cs");

            project2.Add <CodeFile>("ten.cs");
            project2.Add <CodeFile>("aaa.cs");

            project2.Save();

            var project3 = CsProjFile.LoadFrom(project2.FileName);

            project3.All <CodeFile>().Select(x => x.Include)
            .ShouldHaveTheSameElementsAs("aaa.cs", "bar.cs", "foo.cs", "ten.cs");
        }
Example #2
0
        public void can_write_embedded_resources()
        {
            fileSystem.WriteStringToFile("myproj".AppendPath("foo.txt"), "using System.Web;");
            fileSystem.WriteStringToFile("myproj".AppendPath("bar.txt"), "using System.Web;");

            var project = CsProjFile.CreateAtSolutionDirectory("MyProj", "myproj");

            project.Add <EmbeddedResource>("foo.txt");
            project.Add <EmbeddedResource>("bar.txt");

            project.Save();

            var project2 = CsProjFile.LoadFrom(project.FileName);

            project2.All <EmbeddedResource>().Select(x => x.Include)
            .ShouldHaveTheSameElementsAs("bar.txt", "foo.txt");

            project2.Add <EmbeddedResource>("ten.txt");
            project2.Add <EmbeddedResource>("aaa.txt");

            project2.Save();

            var project3 = CsProjFile.LoadFrom(project2.FileName);

            project3.All <EmbeddedResource>().Select(x => x.Include)
            .ShouldHaveTheSameElementsAs("aaa.txt", "bar.txt", "foo.txt", "ten.txt");
        }
        public void SetUp()
        {
            TemplateLibrary.FileSystem.DeleteDirectory("temp-solution");
            TemplateLibrary.FileSystem.CreateDirectory("temp-solution");

            csProjFile = CsProjFile.CreateAtSolutionDirectory("MyProj", "temp-solution");
        }
Example #4
0
        public void can_write_and_read_project_references()
        {
            var include = @"..\OtherProject\OtherProject.csproj";


            var project    = CsProjFile.CreateAtSolutionDirectory("MyProj", "myproj");
            var reference1 = new ProjectReference(include)
            {
                ProjectName = "OtherProject",
                ProjectGuid = Guid.NewGuid()
            };

            project.Add(reference1);

            project.Save();

            var project2 = CsProjFile.LoadFrom(project.FileName);

            var reference2 = project2.Find <ProjectReference>(reference1.Include);

            var all = project2.All <ProjectReference>();

            reference2.ShouldNotBeNull();
            reference2.ProjectName.ShouldEqual(reference1.ProjectName);
            reference2.ProjectGuid.ShouldEqual(reference1.ProjectGuid);
        }
Example #5
0
        public void remove_code_file_2()
        {
            var project = CsProjFile.CreateAtSolutionDirectory("MyProj", "myproj");

            project.Add <CodeFile>("foo.cs");
            project.Add <CodeFile>("bar.cs");

            project.Save();

            var project2 = CsProjFile.LoadFrom(project.FileName);

            project2.All <CodeFile>().Select(x => x.Include)
            .ShouldHaveTheSameElementsAs("bar.cs", "foo.cs");

            project2.Remove <CodeFile>(project2.Find <CodeFile>("bar.cs"));
            project2.All <CodeFile>().Select(x => x.Include)
            .ShouldHaveTheSameElementsAs("foo.cs");

            project2.Save();

            var project3 = CsProjFile.LoadFrom(project.FileName);

            project3.All <CodeFile>().Select(x => x.Include)
            .ShouldHaveTheSameElementsAs("foo.cs");
        }
Example #6
0
        public void sets_the_assembly_name_and_root_namespace_on_creation()
        {
            var project = CsProjFile.CreateAtSolutionDirectory("Goofy", "Directory");

            project.RootNamespace.ShouldEqual("Goofy");
            project.AssemblyName.ShouldEqual("Goofy");
        }
Example #7
0
        public void SetUp()
        {
            new FileSystem().DeleteDirectory("Templated");
            new FileSystem().CreateDirectory("Templated");

            theProject = CsProjFile.CreateAtSolutionDirectory("TemplatedProject", "Templated");
            thePlan    = new ProjectPlan(theProject.ProjectName);
        }
Example #8
0
        public void find_shallow()
        {
            fileSystem.DeleteDirectory("shallow");
            fileSystem.CreateDirectory("shallow");

            CsProjFile.CreateAtSolutionDirectory("Foo", "shallow").Save();

            var location = ProjectFinder.DetermineLocation("shallow".AppendPath("Foo"));

            location.Project.AssemblyName.ShouldEqual("Foo");
            location.Namespace.ShouldEqual("Foo");
            location.RelativePath.ShouldBeEmpty();
        }
Example #9
0
        public void sets_the_CurrentFolder()
        {
            fileSystem.DeleteDirectory("deep1");
            fileSystem.CreateDirectory("deep1");

            CsProjFile.CreateAtSolutionDirectory("Foo", "deep1").Save();

            fileSystem.CreateDirectory("deep1", "Foo", "A");

            var location = ProjectFinder.DetermineLocation("deep1".AppendPath("Foo", "A"));

            location.CurrentFolder.ToFullPath().ShouldEqual(Environment.CurrentDirectory.ToFullPath().AppendPath("deep1", "Foo", "A"));
        }
Example #10
0
        public void SetUp()
        {
            new FileSystem().DeleteDirectory("src");

            var project = CsProjFile.CreateAtSolutionDirectory("Foo", "src");

            project.Save();

            theLocation = new Location
            {
                Project = project
            };
        }
Example #11
0
        public void can_add_a_file_with_build_action_none()
        {
            var project = CsProjFile.CreateAtSolutionDirectory("MyProj", "myproj");
            var content = new None("packages.config");

            project.Add(content);

            project.Save();

            var project2 = CsProjFile.LoadFrom(project.FileName);

            project2.Find <None>("packages.config")
            .CopyToOutputDirectory.ShouldEqual(ContentCopy.Never);
        }
Example #12
0
        public void can_write_system_assemblies()
        {
            var project = CsProjFile.CreateAtSolutionDirectory("MyProj", "myproj");

            project.Add <AssemblyReference>("System.Configuration");
            project.Add <AssemblyReference>("System.Security");

            project.Save();

            var project2 = CsProjFile.LoadFrom(project.FileName);

            project2.Find <AssemblyReference>("System.Configuration").ShouldNotBeNull();
            project2.Find <AssemblyReference>("System.Security").ShouldNotBeNull();
        }
Example #13
0
        public void find_deep_2()
        {
            fileSystem.DeleteDirectory("deep2");
            fileSystem.CreateDirectory("deep2");

            CsProjFile.CreateAtSolutionDirectory("Foo", "deep2").Save();

            fileSystem.CreateDirectory("deep2", "Foo", "A", "B");

            var location = ProjectFinder.DetermineLocation("deep2".AppendPath("Foo", "A", "B"));

            location.Project.AssemblyName.ShouldEqual("Foo");
            location.Namespace.ShouldEqual("Foo.A.B");
            location.RelativePath.ShouldEqual("A\\B");
        }
Example #14
0
        public void can_write_assembly_reference_with_hint_path()
        {
            var hintPath = @"..\packages\RhinoMocks\lib\net\Rhino.Mocks.dll";
            var project  = CsProjFile.CreateAtSolutionDirectory("MyProj", "myproj");

            project.Add(new AssemblyReference("Rhino.Mocks", hintPath));

            project.Save();


            var project2 = CsProjFile.LoadFrom(project.FileName);



            project2.Find <AssemblyReference>("Rhino.Mocks")
            .HintPath.ShouldEqual(hintPath);
        }
Example #15
0
        public void can_add_and_load_always_copy_content()
        {
            var project = CsProjFile.CreateAtSolutionDirectory("MyProj", "myproj");
            var content = new Content("Something.txt")
            {
                CopyToOutputDirectory = ContentCopy.Always
            };

            project.Add(content);

            project.Save();

            var project2 = CsProjFile.LoadFrom(project.FileName);

            project2.Find <Content>("Something.txt")
            .CopyToOutputDirectory.ShouldEqual(ContentCopy.Always);
        }
Example #16
0
        public void read_and_write_with_a_link()
        {
            var project = CsProjFile.CreateAtSolutionDirectory("Foo", Guid.NewGuid().ToString());

            var file = new CodeFile("..\\CommonAssemblyInfo.cs")
            {
                Link = "CommonAssemblyInfo.cs"
            };

            project.Add(file);

            project.Save();

            var project2 = CsProjFile.LoadFrom(project.FileName);

            project2.Find <CodeFile>("..\\CommonAssemblyInfo.cs")
            .Link.ShouldEqual("CommonAssemblyInfo.cs");
        }
Example #17
0
        public void can_add_and_load_IfNewer_copy_content()
        {
            // SAMPLE: adding-content-to-csprojfile
            var project = CsProjFile.CreateAtSolutionDirectory("MyProj", "myproj");
            var content = new Content("Something.txt")
            {
                CopyToOutputDirectory = ContentCopy.IfNewer
            };

            project.Add(content);
            // ENDSAMPLE

            project.Save();

            var project2 = CsProjFile.LoadFrom(project.FileName);

            project2.Find <Content>("Something.txt")
            .CopyToOutputDirectory.ShouldEqual(ContentCopy.IfNewer);
        }
Example #18
0
        public void SetUp()
        {
            new FileSystem().DeleteDirectory("MyLib");
            new FileSystem().CreateDirectory("MyLib");
            theLocation = new Location
            {
                Namespace    = "MyLib.A.B",
                Project      = CsProjFile.CreateAtSolutionDirectory("MyLib", "MyLib"),
                RelativePath = "A/B"
            };

            theViewInput = new ViewInput
            {
                Name    = "MyModel",
                UrlFlag = "foo/bar/model"
            };

            theFile = ViewModelBuilder.BuildCodeFile(theViewInput, theLocation);
        }
Example #19
0
        public void adding_items_is_idempotent()
        {
            fileSystem.WriteStringToFile("myproj".AppendPath("foo.cs"), "using System.Web;");
            fileSystem.WriteStringToFile("myproj".AppendPath("bar.cs"), "using System.Web;");

            var project = CsProjFile.CreateAtSolutionDirectory("MyProj", "myproj");

            project.Add <CodeFile>("foo.cs");
            project.Add <CodeFile>("bar.cs");

            project.Add <CodeFile>("foo.cs");
            project.Add <CodeFile>("bar.cs");


            project.Add <CodeFile>("bar.cs");
            project.Add <CodeFile>("foo.cs");

            project.All <CodeFile>().Select(x => x.Include).ShouldHaveTheSameElementsAs("bar.cs", "foo.cs");
        }
Example #20
0
        public void SetUp()
        {
            var theOriginalLocation = Environment.CurrentDirectory;

            var project = CsProjFile.CreateAtSolutionDirectory("MyProject", "MyProject");

            project.Save();

            var projectPath = project.FileName.ToFullPath();

            var projectFolder = project.FileName.ParentDirectory();

            theCurrentDirectory = projectFolder.AppendPath("Suite", "Tools").ToFullPath();

            new FileSystem().CreateDirectory(theCurrentDirectory);
            Environment.CurrentDirectory = theCurrentDirectory;


            var input = new ViewInput
            {
                Name         = "MyView",
                TemplateFlag = "view.spark",
                UrlFlag      = "foo/bar"
            };

            try
            {
                MvcBuilder.BuildView(input);

                theProject = CsProjFile.LoadFrom(projectPath);
            }
            finally
            {
                Environment.CurrentDirectory = theOriginalLocation;
            }
        }
Example #21
0
        public void creating_a_new_csprojfile_class_library_is_default()
        {
            var project = CsProjFile.CreateAtSolutionDirectory("Foo", "myproj");

            project.ProjectTypes().Single().ShouldEqual(Guid.Parse("FAE04EC0-301F-11D3-BF4B-00C04F79EFBC"));
        }
Example #22
0
        public void creating_a_new_csprojfile_relative_to_a_solution_directory_creates_a_guid()
        {
            var project = CsProjFile.CreateAtSolutionDirectory("Foo", "myproj");

            project.ProjectGuid.ShouldNotEqual(Guid.Empty);
        }