public AddToProjectModule(AddToProjectHandler handler)
 {
     Post["/addtoproject"] = x =>
     {
         var req = this.Bind <AddToProjectRequest>();
         handler.AddToProject(req);
         return(Response.AsJson(true));
     };
 }
 public AddToProjectModule(AddToProjectHandler handler)
 {
     Post["/addtoproject"] = x =>
         {
             var req = this.Bind<AddToProjectRequest>();
             handler.AddToProject(req);
             return Response.AsJson(true);
         };
 }
Beispiel #3
0
        public void ShouldAddNewFileToProject()
        {
            var project = new FakeProject(fileName: @"c:\test\code\fake.csproj");
            project.XmlRepresentation = XDocument.Parse(@"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003""><ItemGroup><Compile Include=""Hello.cs""/></ItemGroup></Project>");
            var expectedXml = XDocument.Parse(@"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003""><ItemGroup><Compile Include=""Hello.cs""/><Compile Include=""files\Test.cs""/></ItemGroup></Project>");

            project.AddFile("some content", @"c:\test\code\files\Test.cs");
            
            var solution = new FakeSolution(@"c:\test\fake.sln");
            solution.Projects.Add(project);

            var request = new AddToProjectRequest
            {
                FileName = @"c:\test\code\files\Test.cs"
            };

            var handler = new AddToProjectHandler(solution);
            handler.AddToProject(request);

            project.AsXml().ToString().ShouldEqual(expectedXml.ToString());
        }
        public void ShouldAlwaysUseWindowsFileSeparatorWhenAddingToProject()
        {
            if (PlatformService.IsUnix) {
                var project = new FakeProject (fileName: @"/test/code/fake.csproj");
                project.XmlRepresentation = XDocument.Parse (@"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003""><ItemGroup><Compile Include=""Hello.cs""/></ItemGroup></Project>");
                var expectedXml = XDocument.Parse (@"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003""><ItemGroup><Compile Include=""Hello.cs""/><Compile Include=""folder\Test.cs""/></ItemGroup></Project>");

                project.AddFile ("some content", @"/test/code/folder/Test.cs");

                var solution = new FakeSolution (@"/test/fake.sln");
                solution.Projects.Add (project);

                var request = new AddToProjectRequest {
                    FileName = @"/test/code/folder/Test.cs"
                };

                var handler = new AddToProjectHandler (solution, new FakeUnixFileSystem());
                handler.AddToProject (request);

                project.AsXml ().ToString ().ShouldEqual (expectedXml.ToString ());
            }
        }
Beispiel #5
0
        public void ShouldNotAddFileToProjectWhenAlreadyExists()
        {
            var project = GetProject (@"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003""><ItemGroup><Compile Include=""Hello.cs""/><Compile Include=""Test.cs""/><Compile Include=""c:\test2\Absolute.cs""/><Compile Include=""..\..\test2\Foreign.cs""/></ItemGroup></Project>");
            var expectedXml = project.AsXml ();

            var solution = new FakeSolution (@"c:\test\fake.sln");
            solution.Projects.Add (project);

            // test relative internal

            var request = new AddToProjectRequest {
                FileName = @"c:\test\code\test.cs"
            };

            var handler = new AddToProjectHandler (solution);
            handler.AddToProject (request);
            project.AsXml ().ToString ().ShouldEqual (expectedXml.ToString ());

            // test absolute
            request = new AddToProjectRequest {
                FileName = @"c:\test2\Absolute.cs"
            };

            handler = new AddToProjectHandler (solution);
            handler.AddToProject (request);
            project.AsXml ().ToString ().ShouldEqual (expectedXml.ToString ());

            // test relative foreign tree

            request = new AddToProjectRequest {
                FileName = @"c:\test2\Foreign.cs"
            };

            handler = new AddToProjectHandler (solution);
            handler.AddToProject (request);
            project.AsXml ().ToString ().ShouldEqual (expectedXml.ToString ());
        }
Beispiel #6
0
        public void ShouldThrowProjectNotFoundExceptionForOrphanProject()
        {
            var solution = new FakeSolution(@"/test/fake.sln");
            var project = new OrphanProject();
            project.Files.Add(new CSharpFile(project, "/test/folder/Test.cs", "Some content..."));
            solution.Projects.Add(project);

            var request = new AddToProjectRequest
            {
                FileName = @"/test/folder/Test.cs"
            };

            var handler = new AddToProjectHandler(solution);
            handler.AddToProject(request);
        }
Beispiel #7
0
        public void ShouldThrowProjectNotFoundExceptionWhenProjectNotFound()
        {
            var project = new FakeProject(fileName: @"/test/code/fake.csproj");
            var solution = new FakeSolution(@"/test/fake.sln");
            solution.Projects.Add(project);

            var request = new AddToProjectRequest
            {
                FileName = @"/test/folder/Test.cs"
            };

            var handler = new AddToProjectHandler(solution);
            handler.AddToProject(request);
        }