|
12 | 12 | // limitations under the License.
|
13 | 13 | // ----------------------------------------------------------------------------------
|
14 | 14 |
|
| 15 | +using System.IO; |
| 16 | + |
15 | 17 | namespace Microsoft.Azure.Commands.StorageSync.Test.UnitTests
|
16 | 18 | {
|
17 | 19 | using Microsoft.Azure.Commands.StorageSync.Evaluation;
|
@@ -139,56 +141,56 @@ public void InvalidArgumentTests()
|
139 | 141 | public void DepthTests()
|
140 | 142 | {
|
141 | 143 | // classic
|
142 |
| - Assert.True(new AfsPath(@"c:").Depth == 1, "invalid depth, expected 1"); |
143 |
| - Assert.True(new AfsPath(@"c:\").Depth == 1, "invalid depth, expected 1"); |
144 |
| - Assert.True(new AfsPath(@"c:\plop").Depth == 1, "invalid depth, expected 1"); |
145 |
| - Assert.True(new AfsPath(@"c:\plop1\plop2\plop3\plop4").Depth == 4, "invalid depth, expected 4"); |
| 144 | + Assert.True(new AfsPath(Path.Combine(@"c:")).Depth == 1, "invalid depth, expected 1"); |
| 145 | + Assert.True(new AfsPath(Path.Combine(@"c:\")).Depth == 1, "invalid depth, expected 1"); |
| 146 | + Assert.True(new AfsPath(Path.Combine(@"c:\", "plop")).Depth == 1, "invalid depth, expected 1"); |
| 147 | + Assert.True(new AfsPath(Path.Combine(@"c:\", "plop1", "plop2", "plop3", "plop4")).Depth == 4, "invalid depth, expected 4"); |
146 | 148 |
|
147 | 149 | // unc+drive
|
148 |
| - Assert.True(new AfsPath(@"\\plop\c$").Depth == 1, "invalid depth, expected 1"); |
149 |
| - Assert.True(new AfsPath(@"\\plop\c$\").Depth == 1, "invalid depth, expected 1"); |
150 |
| - Assert.True(new AfsPath(@"\\plop\c$\plop").Depth == 1, "invalid depth, expected 1"); |
151 |
| - Assert.True(new AfsPath(@"\\plop\c$\plop1\plop2\plop3\plop4").Depth == 4, "invalid depth, expected 4"); |
| 150 | + Assert.True(new AfsPath(Path.Combine(@"\\plop", "c$")).Depth == 1, "invalid depth, expected 1"); |
| 151 | + Assert.True(new AfsPath(Path.Combine(@"\\plop", @"c$\")).Depth == 1, "invalid depth, expected 1"); |
| 152 | + Assert.True(new AfsPath(Path.Combine(@"\\plop", "c$", "plop")).Depth == 1, "invalid depth, expected 1"); |
| 153 | + Assert.True(new AfsPath(Path.Combine(@"\\plop", "c$", "plop1", "plop2", "plop3", "plop4")).Depth == 4, "invalid depth, expected 4"); |
152 | 154 |
|
153 | 155 | // unc+share
|
154 |
| - Assert.True(new AfsPath(@"\\plop\share").Depth == 1, "invalid depth, expected 1"); |
155 |
| - Assert.True(new AfsPath(@"\\plop\share$").Depth == 1, "invalid depth, expected 1"); |
156 |
| - Assert.True(new AfsPath(@"\\plop\share\").Depth == 1, "invalid depth, expected 1"); |
157 |
| - Assert.True(new AfsPath(@"\\plop\share\plop").Depth == 1, "invalid depth, expected 1"); |
158 |
| - Assert.True(new AfsPath(@"\\plop\share\plop1\plop2\plop3\plop4").Depth == 4, "invalid depth, expected 4"); |
| 156 | + Assert.True(new AfsPath(Path.Combine(@"\\plop", "share")).Depth == 1, "invalid depth, expected 1"); |
| 157 | + Assert.True(new AfsPath(Path.Combine(@"\\plop", "share$")).Depth == 1, "invalid depth, expected 1"); |
| 158 | + Assert.True(new AfsPath(Path.Combine(@"\\plop", @"share\")).Depth == 1, "invalid depth, expected 1"); |
| 159 | + Assert.True(new AfsPath(Path.Combine(@"\\plop", "share", "plop")).Depth == 1, "invalid depth, expected 1"); |
| 160 | + Assert.True(new AfsPath(Path.Combine(@"\\plop", "share", "plop1", "plop2", "plop3", "plop4")).Depth == 4, "invalid depth, expected 4"); |
159 | 161 |
|
160 | 162 | // ext
|
161 |
| - Assert.True(new AfsPath(@"\\?\c:").Depth == 1, "invalid depth, expected 1"); |
162 |
| - Assert.True(new AfsPath(@"\\?\c:\").Depth == 1, "invalid depth, expected 1"); |
163 |
| - Assert.True(new AfsPath(@"\\?\c:\plop").Depth == 1, "invalid depth, expected 1"); |
164 |
| - Assert.True(new AfsPath(@"\\?\c:\plop1\plop2\plop3\plop4").Depth == 4, "invalid depth, expected 4"); |
| 163 | + Assert.True(new AfsPath(Path.Combine(@"\\?", "c:")).Depth == 1, "invalid depth, expected 1"); |
| 164 | + Assert.True(new AfsPath(Path.Combine(@"\\?", @"c:\")).Depth == 1, "invalid depth, expected 1"); |
| 165 | + Assert.True(new AfsPath(Path.Combine(@"\\?", "c:", "plop")).Depth == 1, "invalid depth, expected 1"); |
| 166 | + Assert.True(new AfsPath(Path.Combine(@"\\?", "c:", "plop1", "plop2", "plop3", "plop4")).Depth == 4, "invalid depth, expected 4"); |
165 | 167 |
|
166 | 168 | // ext+unc+drive
|
167 |
| - Assert.True(new AfsPath(@"\\?\unc\plop\c$").Depth == 1, "ext+unc+drive: invalid depth, expected 1"); |
168 |
| - Assert.True(new AfsPath(@"\\?\unc\plop\c$\").Depth == 1, "ext+unc+drive: invalid depth, expected 1"); |
169 |
| - Assert.True(new AfsPath(@"\\?\unc\plop\c$\plop").Depth == 1, "ext+unc+drive: invalid depth, expected 1"); |
170 |
| - Assert.True(new AfsPath(@"\\?\unc\plop\c$\plop1\plop2\plop3\plop4").Depth == 4, "ext+unc+drive: invalid depth, expected 4"); |
| 169 | + Assert.True(new AfsPath(Path.Combine(@"\\?", "unc", "plop", "c$")).Depth == 1, "ext+unc+drive: invalid depth, expected 1"); |
| 170 | + Assert.True(new AfsPath(Path.Combine(@"\\?", "unc", "plop", @"c$\")).Depth == 1, "ext+unc+drive: invalid depth, expected 1"); |
| 171 | + Assert.True(new AfsPath(Path.Combine(@"\\?", "unc", "plop", "c$", "plop")).Depth == 1, "ext+unc+drive: invalid depth, expected 1"); |
| 172 | + Assert.True(new AfsPath(Path.Combine(@"\\?", "unc", "plop", "c$", "plop1", "plop2", "plop3", "plop4")).Depth == 4, "ext+unc+drive: invalid depth, expected 4"); |
171 | 173 |
|
172 | 174 | // ext+unc+share
|
173 |
| - Assert.True(new AfsPath(@"\\?\unc\plop\share").Depth == 1, "ext+unc+share: invalid depth, expected 1"); |
174 |
| - Assert.True(new AfsPath(@"\\?\unc\plop\share$").Depth == 1, "ext+unc+share: invalid depth, expected 1"); |
175 |
| - Assert.True(new AfsPath(@"\\?\unc\plop\share\").Depth == 1, "ext+unc+share: invalid depth, expected 1"); |
176 |
| - Assert.True(new AfsPath(@"\\?\unc\plop\share\plop").Depth == 1, "ext+unc+share: invalid depth, expected 1"); |
177 |
| - Assert.True(new AfsPath(@"\\?\unc\plop\share\plop1\plop2\plop3\plop4").Depth == 4, "ext+unc+share: invalid depth, expected 4"); |
| 175 | + Assert.True(new AfsPath(Path.Combine(@"\\?", "unc", "plop", "share")).Depth == 1, "ext+unc+share: invalid depth, expected 1"); |
| 176 | + Assert.True(new AfsPath(Path.Combine(@"\\?", "unc", "plop", "share$")).Depth == 1, "ext+unc+share: invalid depth, expected 1"); |
| 177 | + Assert.True(new AfsPath(Path.Combine(@"\\?", "unc", "plop", @"share\")).Depth == 1, "ext+unc+share: invalid depth, expected 1"); |
| 178 | + Assert.True(new AfsPath(Path.Combine(@"\\?", "unc", "plop", "share", "plop")).Depth == 1, "ext+unc+share: invalid depth, expected 1"); |
| 179 | + Assert.True(new AfsPath(Path.Combine(@"\\?", "unc", "plop", "share", "plop1", "plop2", "plop3", "plop4")).Depth == 4, "ext+unc+share: invalid depth, expected 4"); |
178 | 180 | }
|
179 | 181 |
|
180 | 182 | [Fact]
|
181 | 183 | [Trait(Category.AcceptanceType, Category.CheckIn)]
|
182 | 184 | public void UncPathWithDriveTests()
|
183 | 185 | {
|
184 |
| - string testPath = @"\data"; |
| 186 | + string testPath = @"data"; |
185 | 187 | string testComputerName = "some-computer-name";
|
186 | 188 | char testDriveLetter = 'c';
|
187 |
| - string pathUnderTest = string.Format(@"\\{0}\{1}${2}", testComputerName, testDriveLetter, testPath); |
| 189 | + var pathUnderTest = Path.Combine($@"\\{testComputerName}", $"{testDriveLetter}$", testPath); |
188 | 190 |
|
189 | 191 | AfsPath path = new AfsPath(pathUnderTest);
|
190 | 192 |
|
191 |
| - Assert.True(path.Length == testPath.Length + 2, "invalid path length"); |
| 193 | + Assert.True(path.Length == testPath.Length + 3, "invalid path length"); |
192 | 194 |
|
193 | 195 | Assert.True(path.Depth == 1, "invalid depth");
|
194 | 196 |
|
|
0 commit comments