public void GetFileLocationPath_UriPathCanBeResolved() { string repoPath = "file:///C:/code/myProject/src/"; var run = new Microsoft.CodeAnalysis.Sarif.Run { OriginalUriBaseIds = new Dictionary <string, ArtifactLocation> { ["REPO_ROOT"] = new ArtifactLocation { Uri = new Uri(repoPath), } }, }; var dataCache = new RunDataCache(); int runId = CodeAnalysisResultManager.Instance.GetNextRunIndex(); CodeAnalysisResultManager.Instance.RunIndexToRunDataCache.Add(runId, dataCache); CodeAnalysisResultManager.Instance.CacheUriBasePaths(run); string filePath = @"AnalysisStep.cs"; var artifact = new ArtifactLocation { Uri = new Uri(filePath, UriKind.Relative), UriBaseId = "REPO_ROOT" }; string path = SdkUIUtilities.GetFileLocationPath(artifact, runId); path.Should().Be(@"C:\code\myProject\src\AnalysisStep.cs"); }
public void GetFileLocationPath_UriIsLocalPath() { var dataCache = new RunDataCache(); int runId = CodeAnalysisResultManager.Instance.GetNextRunIndex(); CodeAnalysisResultManager.Instance.RunIndexToRunDataCache.Add(runId, dataCache); string filePath = @"C:\repo\src\AnalysisStep.cs"; var artifact = new ArtifactLocation { Uri = new Uri(filePath, UriKind.Absolute) }; string path = SdkUIUtilities.GetFileLocationPath(artifact, runId); path.Should().Be(filePath); }
public void GetFileLocationPath_UriIsNull() { var dataCache = new RunDataCache(); int runId = CodeAnalysisResultManager.Instance.GetNextRunIndex(); CodeAnalysisResultManager.Instance.RunIndexToRunDataCache.Add(runId, dataCache); var artifact = new ArtifactLocation(); string path = SdkUIUtilities.GetFileLocationPath(artifact, runId); path.Should().BeNull(); artifact = null; path = SdkUIUtilities.GetFileLocationPath(artifact, runId); path.Should().BeNull(); }