Ejemplo n.º 1
0
        public Project Parse(string path)
        {
            var directory   = _pathReader.GetDirectoryName(path);
            var sourceFiles = new List <SourceFile>();

            _xmlReader.Create(path);

            while (_xmlReader.ReadToFollowing("ClCompile"))
            {
                var baseDirectory = directory;
                var filePath      = _xmlReader.GetAttribute("Include");

                if (string.IsNullOrWhiteSpace(filePath))
                {
                    continue;
                }

                filePath = _pathReader.GetFullPath(filePath, baseDirectory);
                sourceFiles.Add(new SourceFile(filePath)
                {
                    Repository = _repositoryRegistry.GetRepositoryFromPath(filePath)
                });
            }

            return(new Project(path, sourceFiles));
        }
        public void ShouldReturnNullRepositoryIfOutsideRepository()
        {
            // Act
            _repositoryRegistry = new ConfigurableRepositoryRegistry(_fileReaderMock.Object, _directoryReaderMock.Object);

            // Assert
            var repositoryFromPath = _repositoryRegistry.GetRepositoryFromPath(@"C:\This\Is\FolderOutsideRepository\SomeFolder\SomeFile.cs");

            repositoryFromPath.Should().BeNull(because: "Scanned files should be inside the repository.");
        }
        public void ShouldGetPathFromRepositoriesProperly()
        {
            // Act
            _repositoryRegistry = new ConfigurableRepositoryRegistry(_fileReaderMock.Object, _directoryReaderMock.Object);

            // Assert
            var repositoryFromPath = _repositoryRegistry.GetRepositoryFromPath(@"C:\This\Is\SomeFirstRepository\SomeFolder\SomeFile.cs");

            repositoryFromPath.Path.Should().Be(@"C:\This\Is\SomeFirstRepository");
        }
Ejemplo n.º 4
0
        public Project Parse(string path)
        {
            var directory   = _pathReader.GetDirectoryName(path);
            var sourceFiles = new List <SourceFile>();

            _xmlReader.Create(path);

            while (_xmlReader.ReadToFollowing("File"))
            {
                var baseDirectory = directory;
                var filePath      = _xmlReader.GetAttribute("RelativePath");
                filePath = _pathReader.GetFullPath(filePath, baseDirectory);
                sourceFiles.Add(new SourceFile(filePath)
                {
                    Repository = _repositoryRegistry.GetRepositoryFromPath(filePath)
                });
            }

            return(new Project(path, sourceFiles));
        }