예제 #1
0
        public void SimpleAddAndRetrieveProject()
        {
            // Initialize engine.
            Engine engine = new Engine(@"c:\");

            // Instantiate new project manager.
            ProjectManager projectManager = new ProjectManager();

            // Set up variables that represent the information we would be getting from 
            // the "MSBuild" task.
            string fullPath = @"c:\rajeev\temp\myapp.proj";
            BuildPropertyGroup globalProperties = new BuildPropertyGroup();
            globalProperties.SetProperty("Configuration", "Debug");

            // Create a new project that matches the information that we're pretending
            // to receive from the MSBuild task.
            Project project1 = new Project(engine);
            project1.FullFileName = fullPath;
            project1.GlobalProperties = globalProperties;

            // Add the new project to the ProjectManager.
            projectManager.AddProject(project1);

            // Try and retrieve the project from the ProjectManager based on the fullpath + globalprops,
            // and make sure we get back the same project we added.
            Assertion.AssertEquals(project1, projectManager.GetProject(fullPath, globalProperties, null));
        }
예제 #2
0
        public void RemoveProjectsByFullPath()
        {
            // Initialize engine.  Need two separate engines because we don't allow two
            // projects with the same full path to be loaded in the same Engine.
            Engine engine1 = new Engine(@"c:\");
            Engine engine2 = new Engine(@"c:\");

            // Instantiate new project manager.
            ProjectManager projectManager = new ProjectManager();

            // Set up a global property group.
            BuildPropertyGroup globalProperties = new BuildPropertyGroup();
            globalProperties.SetProperty("Configuration", "Release");

            // Create a few new projects.
            Project project1 = new Project(engine1);
            project1.FullFileName = @"c:\rajeev\temp\myapp.proj";
            project1.GlobalProperties = globalProperties;

            Project project2 = new Project(engine1);
            project2.FullFileName = @"c:\blah\foo.proj";
            project2.GlobalProperties = globalProperties;

            Project project3 = new Project(engine2);
            project3.FullFileName = @"c:\blah\foo.proj";
            globalProperties.SetProperty("Configuration", "Debug");
            project3.GlobalProperties = globalProperties;

            // Add the new projects to the ProjectManager.
            projectManager.AddProject(project1);
            projectManager.AddProject(project2);
            projectManager.AddProject(project3);

            // Remove all projects with the full path "c:\blah\foo.proj" (case insenstively).
            projectManager.RemoveProjects(@"c:\BLAH\FOO.Proj");

            // Make sure project 1 is still there.
            Assertion.AssertEquals(project1, projectManager.GetProject(project1.FullFileName, project1.GlobalProperties, null));

            // Make sure projects 2 and 3 are gone.
            Assertion.AssertNull(projectManager.GetProject(project2.FullFileName, project2.GlobalProperties, null));
            Assertion.AssertNull(projectManager.GetProject(project3.FullFileName, project3.GlobalProperties, null));
        }
예제 #3
0
        public void SimpleAddAndRetrieveProjectWithDifferentFullPath()
        {
            // Initialize engine.
            Engine engine = new Engine(@"c:\");

            // Instantiate new project manager.
            ProjectManager projectManager = new ProjectManager();

            // Set up variables that represent the information we would be getting from 
            // the "MSBuild" task.
            BuildPropertyGroup globalProperties = new BuildPropertyGroup();
            globalProperties.SetProperty("Configuration", "Release");

            // Create a new project that matches the information that we're pretending
            // to receive from the MSBuild task.
            Project project1 = new Project(engine);
            project1.FullFileName = @"c:\rajeev\temp\myapp.proj";
            project1.GlobalProperties = globalProperties;

            // Add the new project to the ProjectManager.
            projectManager.AddProject(project1);

            // Now search for a project with a different full path but same set of global
            // properties.  We expect to get back null, because no such project exists.
            Assertion.AssertNull(projectManager.GetProject(@"c:\blah\wrong.proj", globalProperties, null));
        }