public void CanResolveWorkspaceRelativePath() { string workspacePath = TestUtilities.NormalizePath("c:/Test/Workspace/"); string testPathInside = TestUtilities.NormalizePath("c:/Test/Workspace/SubFolder/FilePath.ps1"); string testPathOutside = TestUtilities.NormalizePath("c:/Test/PeerPath/FilePath.ps1"); string testPathAnotherDrive = TestUtilities.NormalizePath("z:/TryAndFindMe/FilePath.ps1"); WorkspaceService workspace = new WorkspaceService(NullLoggerFactory.Instance); // Test without a workspace path Assert.Equal(testPathOutside, workspace.GetRelativePath(testPathOutside)); string expectedInsidePath = TestUtilities.NormalizePath("SubFolder/FilePath.ps1"); string expectedOutsidePath = TestUtilities.NormalizePath("../PeerPath/FilePath.ps1"); // Test with a workspace path workspace.WorkspacePath = workspacePath; Assert.Equal(expectedInsidePath, workspace.GetRelativePath(testPathInside)); Assert.Equal(expectedOutsidePath, workspace.GetRelativePath(testPathOutside)); Assert.Equal(testPathAnotherDrive, workspace.GetRelativePath(testPathAnotherDrive)); }
public string GetWorkspaceRelativePath(string filePath) => _workspaceService.GetRelativePath(filePath);