コード例 #1
0
        public void GetRepositoryRoot_WhenDotGitIsPresent_ReturnsTheDirectortyContainingDotGit()
        {
            string productDirectory = Path.GetDirectoryName(FileDiffingUnitTests.GetProductDirectory());
            string repoDirectory    = Directory.GetParent(productDirectory).FullName;

            var gitHelper = new GitHelper();

            gitHelper.GetRepositoryRoot(productDirectory).Should().BeEquivalentTo(repoDirectory);
        }
コード例 #2
0
        public void GetRepositoryRoot_ByDefault_PopulatesTheDirectoryToRepoRootCache()
        {
            // Returns '\src\' location within repo, e.g., 'c:\src\sarif-sdk\src'
            string productDirectory = Path.GetDirectoryName(FileDiffingUnitTests.GetProductDirectory());
            string repoDirectory    = Directory.GetParent(productDirectory).FullName;

            var gitHelper = new GitHelper();

            gitHelper.GetRepositoryRoot(repoDirectory).Should().BeEquivalentTo(repoDirectory);
            gitHelper.GetRepositoryRoot(productDirectory).Should().BeEquivalentTo(repoDirectory);

            // Verify that the API returns the correct results whether or not the cache is in use.
            gitHelper.GetRepositoryRoot(repoDirectory).Should().BeEquivalentTo(repoDirectory);
            gitHelper.GetRepositoryRoot(productDirectory).Should().BeEquivalentTo(repoDirectory);

            gitHelper.directoryToRepoRootPathDictionary.Count.Should().Be(2);
            gitHelper.directoryToRepoRootPathDictionary[repoDirectory].Should().BeEquivalentTo(repoDirectory);
            gitHelper.directoryToRepoRootPathDictionary[productDirectory].Should().BeEquivalentTo(repoDirectory);
        }