Beispiel #1
0
        public void ProjectParser_GetReferencedFilesForProject_IgnoresReferencedAssemblies()
        {
            string nonReferencedFile1 = @"Microsoft.CSharp";
            string nonReferencedFile2 = @"System.Data";
            string referencedFile1    = @"Controllers\Controller.cs";
            string referencedFile2    = @"Web.config";

            string projectXml = String.Format(
                @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
					<ItemGroup>
						<Reference Include=""{0}"" />
						<Reference Include=""{1}"" />
					</ItemGroup>
					<ItemGroup>
						<Item Include=""{2}"" />
						<Item Include=""{3}"" />
					</ItemGroup>
				</Project>"                , nonReferencedFile1, nonReferencedFile2, referencedFile1, referencedFile2);

            XElement projectElement = XElement.Parse(projectXml);

            ProjectParser          projectParser          = new ProjectParser();
            ReferencedProjectFiles referencedProjectFiles = projectParser.GetReferencedFilesForProject(projectElement);

            Assert.False(referencedProjectFiles.IsFileReferenced(nonReferencedFile1));
            Assert.False(referencedProjectFiles.IsFileReferenced(nonReferencedFile2));

            Assert.True(referencedProjectFiles.IsFileReferenced(referencedFile1));
            Assert.True(referencedProjectFiles.IsFileReferenced(referencedFile2));
        }
Beispiel #2
0
        public void ProjectParser_GetReferencedFilesForProject_ParsesAllFilesFromMultipleItemGroups()
        {
            string referencedFile1 = @"Controllers\Controller.cs";
            string referencedFile2 = @"Models\Model.cs";
            string referencedFile3 = @"Views\View.cshtml";
            string referencedFile4 = @"Web.config";

            string projectXml = String.Format(
                @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
					<ItemGroup>
						<Item Include=""{0}"" />
						<Item Include=""{1}"" />
					</ItemGroup>
					<ItemGroup>
						<Item Include=""{2}"" />
						<Item Include=""{3}"" />
					</ItemGroup>
				</Project>"                , referencedFile1, referencedFile2, referencedFile3, referencedFile4);

            XElement projectElement = XElement.Parse(projectXml);

            ProjectParser          projectParser          = new ProjectParser();
            ReferencedProjectFiles referencedProjectFiles = projectParser.GetReferencedFilesForProject(projectElement);

            Assert.True(referencedProjectFiles.IsFileReferenced(referencedFile1));
            Assert.True(referencedProjectFiles.IsFileReferenced(referencedFile2));
            Assert.True(referencedProjectFiles.IsFileReferenced(referencedFile3));
            Assert.True(referencedProjectFiles.IsFileReferenced(referencedFile4));
        }
Beispiel #3
0
        public void ReferencedProjectFiles_Constructor_DoesNotReferenceAnyFiles()
        {
            string filePath = @"c:\temp\Test.cs";

            ReferencedProjectFiles referencedProjectFiles = new ReferencedProjectFiles();

            Assert.False(referencedProjectFiles.IsFileReferenced(filePath));
        }
Beispiel #4
0
        public void ReferencedProjectFiles_AddFile_ReferencesFile()
        {
            string filePath = @"c:\temp\Test.cs";

            ReferencedProjectFiles referencedProjectFiles = new ReferencedProjectFiles();

            referencedProjectFiles.AddFile(filePath);

            Assert.True(referencedProjectFiles.IsFileReferenced(filePath));
        }
Beispiel #5
0
        public void ReferencedProjectFiles_IsFileReferenced_ReturnsFalseForSameFileDifferentDirectory()
        {
            string referencedFilePath    = @"c:\temp\Test.cs";
            string nonReferencedFilePath = @"c:\temp2\Test.cs";

            ReferencedProjectFiles referencedProjectFiles = new ReferencedProjectFiles();

            referencedProjectFiles.AddFile(referencedFilePath);

            Assert.False(referencedProjectFiles.IsFileReferenced(nonReferencedFilePath));
        }