Skip to content

Commit 1ffb5f3

Browse files
committed
Attempting to fix test paths for Linux.
1 parent c2c9c39 commit 1ffb5f3

File tree

2 files changed

+38
-34
lines changed

2 files changed

+38
-34
lines changed

src/ResourceManager/StorageSync/Commands.StorageSync.Test/UnitTests/AfsPathTests.cs

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using System.IO;
16+
1517
namespace Microsoft.Azure.Commands.StorageSync.Test.UnitTests
1618
{
1719
using Microsoft.Azure.Commands.StorageSync.Evaluation;
@@ -139,56 +141,56 @@ public void InvalidArgumentTests()
139141
public void DepthTests()
140142
{
141143
// 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");
146148

147149
// 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");
152154

153155
// 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");
159161

160162
// 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");
165167

166168
// 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");
171173

172174
// 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");
178180
}
179181

180182
[Fact]
181183
[Trait(Category.AcceptanceType, Category.CheckIn)]
182184
public void UncPathWithDriveTests()
183185
{
184-
string testPath = @"\data";
186+
string testPath = @"data";
185187
string testComputerName = "some-computer-name";
186188
char testDriveLetter = 'c';
187-
string pathUnderTest = string.Format(@"\\{0}\{1}${2}", testComputerName, testDriveLetter, testPath);
189+
var pathUnderTest = Path.Combine($@"\\{testComputerName}", $"{testDriveLetter}$", testPath);
188190

189191
AfsPath path = new AfsPath(pathUnderTest);
190192

191-
Assert.True(path.Length == testPath.Length + 2, "invalid path length");
193+
Assert.True(path.Length == testPath.Length + 3, "invalid path length");
192194

193195
Assert.True(path.Depth == 1, "invalid depth");
194196

src/ResourceManager/StorageSync/Commands.StorageSync.Test/UnitTests/MaximumTreeDepthValidationTest.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using System.IO;
16+
1517
namespace Microsoft.Azure.Commands.StorageSync.Test.UnitTests
1618
{
1719
using Microsoft.Azure.Commands.StorageSync.Evaluation.Interfaces;
@@ -29,7 +31,7 @@ public void WhenLocalFileIsDeeperThanMaxDepthValidationResultIsError()
2931
int maxDepth = 3;
3032
IConfiguration configuration = MockFactory.ConfigurationWithMaximumDepthOf(maxDepth);
3133
MaximumTreeDepthValidation validation = new MaximumTreeDepthValidation(configuration);
32-
string tooDeepFile = @"C:\first\second\third\fourth";
34+
var tooDeepFile = Path.Combine(@"C:\", "first", "second", "third", "fourth");
3335
IFileInfo file = MockFactory.FileWithPath(tooDeepFile);
3436

3537
// Exercise
@@ -47,7 +49,7 @@ public void WhenUNCFileIsDeeperThanMaxDepthValidationResultIsError()
4749
int maxDepth = 3;
4850
IConfiguration configuration = MockFactory.ConfigurationWithMaximumDepthOf(maxDepth);
4951
MaximumTreeDepthValidation validation = new MaximumTreeDepthValidation(configuration);
50-
string tooDeepFile = @"\\server\share$\first\second\third\fourth";
52+
var tooDeepFile = Path.Combine(@"\\server", "share$", "first", "second", "third", "fourth");
5153
IFileInfo file = MockFactory.FileWithPath(tooDeepFile);
5254

5355
// Exercise
@@ -65,7 +67,7 @@ public void WhenLocalFileDepthIsEqualToMaxDepthValidationResultIsSuccess()
6567
int maxDepth = 4;
6668
IConfiguration configuration = MockFactory.ConfigurationWithMaximumDepthOf(maxDepth);
6769
MaximumTreeDepthValidation validation = new MaximumTreeDepthValidation(configuration);
68-
string path = @"C:\first\second\third\fourth";
70+
var path = Path.Combine(@"C:\", "first", "second", "third", "fourth");
6971
IFileInfo file = MockFactory.FileWithPath(path);
7072

7173
// Exercise
@@ -83,7 +85,7 @@ public void WhenUNCFileDepthIsEqualToMaxDepthValidationResultIsSuccess()
8385
int maxDepth = 4;
8486
IConfiguration configuration = MockFactory.ConfigurationWithMaximumDepthOf(maxDepth);
8587
MaximumTreeDepthValidation validation = new MaximumTreeDepthValidation(configuration);
86-
string path = @"\\server\share$\first\second\third\fourth";
88+
var path = Path.Combine(@"\\server", "share$", "first", "second", "third", "fourth");
8789
IFileInfo file = MockFactory.FileWithPath(path);
8890

8991
// Exercise
@@ -101,7 +103,7 @@ public void WhenLocalDirectoryTreeDepthIsEqualToMaxDepthValidationResultIsSucces
101103
int maxDepth = 4;
102104
IConfiguration configuration = MockFactory.ConfigurationWithMaximumDepthOf(maxDepth);
103105
MaximumTreeDepthValidation validation = new MaximumTreeDepthValidation(configuration);
104-
string path = @"C:\first\second\third\fourth";
106+
var path = Path.Combine(@"C:\", "first", "second", "third", "fourth");
105107
IDirectoryInfo directory = MockFactory.DirectoryWithPath(path);
106108

107109
// Exercise

0 commit comments

Comments
 (0)