5
5
6
6
using System ;
7
7
using System . IO ;
8
+ using System . Collections . Generic ;
8
9
using Microsoft . PowerShell . EditorServices . Test . Shared ;
9
10
using Microsoft . PowerShell . EditorServices . Utility ;
10
11
using Xunit ;
11
12
13
+ #if CoreCLR
14
+ using System . Runtime . InteropServices ;
15
+ #endif
16
+
12
17
namespace Microsoft . PowerShell . EditorServices . Test . Session
13
18
{
14
19
public class WorkspaceTests
@@ -76,15 +81,7 @@ public void CanDetermineIsPathInMemory()
76
81
}
77
82
78
83
[ Theory ( ) ]
79
- [ InlineData ( "file:///C%3A/banana/" , @"C:\banana\" ) ]
80
- [ InlineData ( "file:///C%3A/banana/ex.ps1" , @"C:\banana\ex.ps1" ) ]
81
- [ InlineData ( "file:///E%3A/Path/to/awful%23path" , @"E:\Path\to\awful#path" ) ]
82
- [ InlineData ( "file:///path/with/no/drive" , @"C:\path\with\no\drive" ) ]
83
- [ InlineData ( "file:///path/wi[th]/squ[are/brackets/" , @"C:\path\wi[th]\squ[are\brackets\" ) ]
84
- [ InlineData ( "file:///Carrots/A%5Ere/Good/" , @"C:\Carrots\A^re\Good\" ) ]
85
- [ InlineData ( "file:///Users/barnaby/%E8%84%9A%E6%9C%AC/Reduce-Directory" , @"C:\Users\barnaby\脚本\Reduce-Directory" ) ]
86
- [ InlineData ( "file:///C%3A/Program%20Files%20%28x86%29/PowerShell/6/pwsh.exe" , @"C:\Program Files (x86)\PowerShell\6\pwsh.exe" ) ]
87
- [ InlineData ( "file:///home/maxim/test%20folder/%D0%9F%D0%B0%D0%BF%D0%BA%D0%B0/helloworld.ps1" , @"C:\home\maxim\test folder\Папка\helloworld.ps1" ) ]
84
+ [ MemberData ( nameof ( PathResolutionInput ) ) ]
88
85
public void CorrectlyResolvesPaths ( string givenPath , string expectedPath )
89
86
{
90
87
Workspace workspace = new Workspace ( PowerShellVersion , Logging . NullLogger ) ;
@@ -93,5 +90,52 @@ public void CorrectlyResolvesPaths(string givenPath, string expectedPath)
93
90
94
91
Assert . Equal ( expectedPath , resolvedPath ) ;
95
92
}
93
+
94
+ public static IEnumerable < object [ ] > PathResolutionInput
95
+ {
96
+ get
97
+ {
98
+ #if ! CoreCLR
99
+ return new [ ] {
100
+ new [ ] { "file:///C%3A/banana/" , @"C:\banana\" } ,
101
+ new [ ] { "file:///C%3A/banana/ex.ps1" , @"C:\banana\ex.ps1" } ,
102
+ new [ ] { "file:///E%3A/Path/to/awful%23path" , @"E:\Path\to\awful#path" } ,
103
+ new [ ] { "file:///path/with/no/drive" , @"C:\path\with\no\drive" } ,
104
+ new [ ] { "file:///path/wi[th]/squ[are/brackets/" , @"C:\path\wi[th]\squ[are\brackets\" } ,
105
+ new [ ] { "file:///Carrots/A%5Ere/Good/" , @"C:\Carrots\A^re\Good\" } ,
106
+ new [ ] { "file:///Users/barnaby/%E8%84%9A%E6%9C%AC/Reduce-Directory" , @"C:\Users\barnaby\脚本\Reduce-Directory" } ,
107
+ new [ ] { "file:///C%3A/Program%20Files%20%28x86%29/PowerShell/6/pwsh.exe" , @"C:\Program Files (x86)\PowerShell\6\pwsh.exe" } ,
108
+ new [ ] { "file:///home/maxim/test%20folder/%D0%9F%D0%B0%D0%BF%D0%BA%D0%B0/helloworld.ps1" , @"C:\home\maxim\test folder\Папка\helloworld.ps1" }
109
+ } ;
110
+ #else
111
+ if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
112
+ {
113
+ return new [ ] {
114
+ new [ ] { "file:///C%3A/banana/" , @"C:\banana\" } ,
115
+ new [ ] { "file:///C%3A/banana/ex.ps1" , @"C:\banana\ex.ps1" } ,
116
+ new [ ] { "file:///E%3A/Path/to/awful%23path" , @"E:\Path\to\awful#path" } ,
117
+ new [ ] { "file:///path/with/no/drive" , @"C:\path\with\no\drive" } ,
118
+ new [ ] { "file:///path/wi[th]/squ[are/brackets/" , @"C:\path\wi[th]\squ[are\brackets\" } ,
119
+ new [ ] { "file:///Carrots/A%5Ere/Good/" , @"C:\Carrots\A^re\Good\" } ,
120
+ new [ ] { "file:///Users/barnaby/%E8%84%9A%E6%9C%AC/Reduce-Directory" , @"C:\Users\barnaby\脚本\Reduce-Directory" } ,
121
+ new [ ] { "file:///C%3A/Program%20Files%20%28x86%29/PowerShell/6/pwsh.exe" , @"C:\Program Files (x86)\PowerShell\6\pwsh.exe" } ,
122
+ new [ ] { "file:///home/maxim/test%20folder/%D0%9F%D0%B0%D0%BF%D0%BA%D0%B0/helloworld.ps1" , @"C:\home\maxim\test folder\Папка\helloworld.ps1" }
123
+ } ;
124
+ }
125
+
126
+ return new [ ] {
127
+ new [ ] { "file:///banana/" , "/banana/" } ,
128
+ new [ ] { "file:///banana/ex.ps1" , "/banana/ex.ps1" } ,
129
+ new [ ] { "file://Path/to/awful%23path" , "/Path/to/awful#path" } ,
130
+ new [ ] { "file:///path/wi[th]/squ[are/brackets/" , "/path/wi[th]/sq[are/brackets/" } ,
131
+ new [ ] { "file:///path%5Cto/file" , "/path\\ to/file" } ,
132
+ new [ ] { "file:///Carrots/A%5Ere/Good/" , "/Carrots/A^re/Good/" } ,
133
+ new [ ] { "file:///Users/barnaby/%E8%84%9A%E6%9C%AC/Reduce-Directory" , "/Users/barnaby/脚本/Reduce-Directory" } ,
134
+ new [ ] { "file:///Program%20Files%20%28x86%29/PowerShell/6/pwsh.exe" , "/Program Files (x86)/PowerShell/6/pwsh.exe" } ,
135
+ new [ ] { "file:///home/maxim/test%20folder/%D0%9F%D0%B0%D0%BF%D0%BA%D0%B0/helloworld.ps1" , @"/home/maxim/test folder/Папка/helloworld.ps1" }
136
+ } ;
137
+ #endif
138
+ }
139
+ }
96
140
}
97
141
}
0 commit comments