コード例 #1
0
        public void SolutionNotFound()
        {
            GetSolutionProjects task = new GetSolutionProjects();
            task.BuildEngine = new MockBuild();

            task.Solution = "filenamethatcannotexist.sln";
            bool retVal = task.Execute();

            Assert.IsFalse(retVal);
        }
コード例 #2
0
        public void SolutionNotFound()
        {
            GetSolutionProjects task = new GetSolutionProjects();

            task.BuildEngine = new MockBuild();

            task.Solution = "filenamethatcannotexist.sln";
            bool retVal = task.Execute();

            Assert.IsFalse(retVal);
        }
コード例 #3
0
        public void The_WellKnown_item_metadata_can_be_accessed_on_returned_projects()
        {
            // http://msdn2.microsoft.com/en-us/library/ms164313.aspx
            GetSolutionProjects task = new GetSolutionProjects();

            task.BuildEngine = new MockBuild();
            task.Solution    = Path.Combine(TaskUtility.GetProjectRootDirectory(true), @"Source\MSBuild.Community.Tasks.Tests\Solution\TestSolution.sln");
            Assert.IsTrue(task.Execute());

            Assert.AreEqual("TestProject1", task.Output[0].GetMetadata("Filename"));
        }
コード例 #4
0
        public void Solution_folders_are_not_returned_as_projects()
        {
            GetSolutionProjects task = new GetSolutionProjects();

            task.BuildEngine = new MockBuild();
            task.Solution    = Path.Combine(TaskUtility.GetProjectRootDirectory(true), @"Source\MSBuild.Community.Tasks.Tests\Solution\TestSolution.sln");
            Assert.IsTrue(task.Execute());
            foreach (ITaskItem project in task.Output)
            {
                Assert.AreNotEqual("TestFolder1", project.GetMetadata("ProjectName"));
            }
        }
コード例 #5
0
        public void GetSolutionProjects()
        {
            GetSolutionProjects task = new GetSolutionProjects();

            task.BuildEngine = new MockBuild();
            task.Solution    = Path.Combine(TaskUtility.getProjectRootDirectory(true), @"Source\MSBuild.Community.Tasks.Tests\Solution\TestSolution.sln");

            Assert.IsTrue(task.Execute());

            ITaskItem[] items = task.Output;

            Assert.AreEqual(3, items.Length);
            for (int ndx = 1; ndx < 4; ndx++)
            {
                Assert.AreEqual(string.Format("TestProject{0}\\TestProject{0}.csproj", ndx), items[ndx - 1].ItemSpec);
                Assert.AreEqual(string.Concat("TestProject", ndx.ToString()), items[ndx - 1].GetMetadata("ProjectName"));
            }
        }
コード例 #6
0
        public void GetSolutionProjects()
        {
            GetSolutionProjects task = new GetSolutionProjects();

            task.BuildEngine = new MockBuild();
            task.Solution    = Path.Combine(TaskUtility.GetProjectRootDirectory(true), @"Source\MSBuild.Community.Tasks.Tests\Solution\TestSolution.sln");

            Assert.IsTrue(task.Execute());

            ITaskItem[] items = task.Output;
            string      expectedProjectPath;
            string      actualProjectPath;
            string      expectedProjectName;
            string      actualProjectName;

            Assert.AreEqual(4, items.Length);
            for (int i = 0; i < 3; i++)
            {
                expectedProjectPath = string.Format("TestProject{0}\\TestProject{0}.csproj", i + 1);
                actualProjectPath   = items[i].GetMetadata("ProjectPath");
                expectedProjectName = string.Format("TestProject{0}", i + 1);
                actualProjectName   = items[i].GetMetadata("ProjectName");

                Assert.AreEqual(expectedProjectPath, actualProjectPath);
                Assert.AreEqual(expectedProjectName, actualProjectName);
            }

            //Added test to check handling of projects with spaces in the name
            expectedProjectPath = "Test Project4\\Test Project4.csproj";
            actualProjectPath   = items[3].GetMetadata("ProjectPath");
            expectedProjectName = "Test Project4";
            actualProjectName   = items[3].GetMetadata("ProjectName");

            Assert.AreEqual(expectedProjectPath, actualProjectPath);
            Assert.AreEqual(expectedProjectName, actualProjectName);

            //Added test for reading the GUID attribute
            string expectedGUID = "{D6CFCEDB-15CF-4EB6-87FB-8A5113727718}";
            string actualGUID   = items[3].GetMetadata("ProjectGUID");

            Assert.AreEqual(expectedGUID, actualGUID);
        }
コード例 #7
0
        public void The_item_spec_will_contain_the_full_path_to_the_project_file()
        {
            GetSolutionProjects task = new GetSolutionProjects();

            task.BuildEngine = new MockBuild();
            string msbuildProjectDirectory = TaskUtility.GetProjectRootDirectory(true);
            string solutionDirectory       = Path.Combine(msbuildProjectDirectory, @"Source\MSBuild.Community.Tasks.Tests\Solution");

            task.Solution = Path.Combine(solutionDirectory, @"TestSolution.sln");
            Assert.IsTrue(task.Execute());
            ITaskItem[] items = task.Output;

            // Make sure the test .sln file is setup the way we expect
            string projectEntryInSolutionFile = @"TestProject1\TestProject1.csproj";

            Assert.AreEqual(projectEntryInSolutionFile, items[0].GetMetadata("ProjectPath"), "The TestSolution.sln file has changed since this test was written. Please fix the file or this test so that the expectations are in synch.");

            string expectedFullPathToProjectFile = Path.Combine(solutionDirectory, projectEntryInSolutionFile);

            Assert.AreEqual(expectedFullPathToProjectFile, items[0].ItemSpec, "The ItemSpec should contain the full path to the contained project file.");
        }
コード例 #8
0
        public void GetSolutionProjects()
        {
            GetSolutionProjects task = new GetSolutionProjects();
            task.BuildEngine = new MockBuild();
            task.Solution = Path.Combine(TaskUtility.getProjectRootDirectory(true), @"Source\MSBuild.Community.Tasks.Tests\Solution\TestSolution.sln");

            Assert.IsTrue(task.Execute());

            ITaskItem[] items = task.Output;
            string expectedProjectPath;
            string actualProjectPath;
            string expectedProjectName;
            string actualProjectName;

            Assert.AreEqual(4, items.Length);
            for (int i = 0; i < 3; i++)
            {
                expectedProjectPath = string.Format("TestProject{0}\\TestProject{0}.csproj", i + 1);
                actualProjectPath = items[i].GetMetadata("ProjectPath");
                expectedProjectName = string.Format("TestProject{0}", i + 1);
                actualProjectName = items[i].GetMetadata("ProjectName");

                Assert.AreEqual(expectedProjectPath, actualProjectPath);
                Assert.AreEqual(expectedProjectName, actualProjectName);
            }

            //Added test to check handling of projects with spaces in the name
            expectedProjectPath = "Test Project4\\Test Project4.csproj";
            actualProjectPath = items[3].GetMetadata("ProjectPath");
            expectedProjectName = "Test Project4";
            actualProjectName = items[3].GetMetadata("ProjectName");

            Assert.AreEqual(expectedProjectPath, actualProjectPath);
            Assert.AreEqual(expectedProjectName, actualProjectName);

            //Added test for reading the GUID attribute
            string expectedGUID = "{D6CFCEDB-15CF-4EB6-87FB-8A5113727718}";
            string actualGUID = items[3].GetMetadata("ProjectGUID");
            Assert.AreEqual(expectedGUID, actualGUID);
        }
コード例 #9
0
        public void The_WellKnown_item_metadata_can_be_accessed_on_returned_projects()
        {
            // http://msdn2.microsoft.com/en-us/library/ms164313.aspx
            GetSolutionProjects task = new GetSolutionProjects();
            task.BuildEngine = new MockBuild();
            task.Solution = Path.Combine(TaskUtility.getProjectRootDirectory(true), @"Source\MSBuild.Community.Tasks.Tests\Solution\TestSolution.sln");
            Assert.IsTrue(task.Execute());

            Assert.AreEqual("TestProject1", task.Output[0].GetMetadata("Filename"));
        }
コード例 #10
0
        public void The_item_spec_will_contain_the_full_path_to_the_project_file()
        {
            GetSolutionProjects task = new GetSolutionProjects();
            task.BuildEngine = new MockBuild();
            string msbuildProjectDirectory = TaskUtility.getProjectRootDirectory(true);
            string solutionDirectory = Path.Combine(msbuildProjectDirectory, @"Source\MSBuild.Community.Tasks.Tests\Solution");
            task.Solution = Path.Combine(solutionDirectory, @"TestSolution.sln");
            Assert.IsTrue(task.Execute());
            ITaskItem[] items = task.Output;

            // Make sure the test .sln file is setup the way we expect
            string projectEntryInSolutionFile = @"TestProject1\TestProject1.csproj";
            Assert.AreEqual(projectEntryInSolutionFile, items[0].GetMetadata("ProjectPath"), "The TestSolution.sln file has changed since this test was written. Please fix the file or this test so that the expectations are in synch.");

            string expectedFullPathToProjectFile = Path.Combine(solutionDirectory, projectEntryInSolutionFile);

            Assert.AreEqual(expectedFullPathToProjectFile, items[0].ItemSpec, "The ItemSpec should contain the full path to the contained project file.");
        }
コード例 #11
0
 public void Solution_folders_are_not_returned_as_projects()
 {
     GetSolutionProjects task = new GetSolutionProjects();
     task.BuildEngine = new MockBuild();
     task.Solution = Path.Combine(TaskUtility.GetProjectRootDirectory(true), @"Source\MSBuild.Community.Tasks.Tests\Solution\TestSolution.sln");
     Assert.IsTrue(task.Execute());
     foreach (ITaskItem project in task.Output)
     {
         Assert.AreNotEqual("TestFolder1", project.GetMetadata("ProjectName"));
     }
 }