Skip to content

Commit 9e19755

Browse files
committed
Use verbatim strings in tests' file paths
1 parent c60d8d4 commit 9e19755

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

test/PowerShellEditorServices.Test/Extensions/ExtensionCommandTests.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void Dispose()
5151
[Fact]
5252
public async Task CanRegisterAndInvokeCommandWithCmdletName()
5353
{
54-
string filePath = TestUtilities.NormalizePath("C:\\Temp\\Test.ps1");
54+
string filePath = TestUtilities.NormalizePath(@"C:\Temp\Test.ps1");
5555
ScriptFile currentFile = new(new Uri(filePath), "This is a test file", new Version("7.0"));
5656
EditorContext editorContext = new(
5757
editorOperations: null,
@@ -87,7 +87,7 @@ await psesHost.ExecutePSCommandAsync(
8787
[Fact]
8888
public async Task CanRegisterAndInvokeCommandWithScriptBlock()
8989
{
90-
string filePath = TestUtilities.NormalizePath("C:\\Temp\\Test.ps1");
90+
string filePath = TestUtilities.NormalizePath(@"C:\Temp\Test.ps1");
9191
ScriptFile currentFile = new(new Uri(filePath), "This is a test file", new Version("7.0"));
9292
EditorContext editorContext = new(
9393
editorOperations: null,
@@ -149,7 +149,7 @@ await psesHost.ExecutePSCommandAsync(
149149
[Fact]
150150
public async Task CanUnregisterCommand()
151151
{
152-
string filePath = TestUtilities.NormalizePath("C:\\Temp\\Test.ps1");
152+
string filePath = TestUtilities.NormalizePath(@"C:\Temp\Test.ps1");
153153
ScriptFile currentFile = new(new Uri(filePath), "This is a test file", new Version("7.0"));
154154
EditorContext editorContext = new(
155155
editorOperations: null,

test/PowerShellEditorServices.Test/Session/PathEscapingTests.cs

+10-10
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ public class PathEscapingTests
1212
[Theory]
1313
[InlineData("DebugTest.ps1", "DebugTest.ps1")]
1414
[InlineData("../../DebugTest.ps1", "../../DebugTest.ps1")]
15-
[InlineData("C:\\Users\\me\\Documents\\DebugTest.ps1", "C:\\Users\\me\\Documents\\DebugTest.ps1")]
15+
[InlineData(@"C:\Users\me\Documents\DebugTest.ps1", @"C:\Users\me\Documents\DebugTest.ps1")]
1616
[InlineData("/home/me/Documents/weird&folder/script.ps1", "/home/me/Documents/weird&folder/script.ps1")]
1717
[InlineData("./path/with some/spaces", "./path/with some/spaces")]
18-
[InlineData("C:\\path\\with[some]brackets\\file.ps1", "C:\\path\\with`[some`]brackets\\file.ps1")]
19-
[InlineData("C:\\look\\an*\\here.ps1", "C:\\look\\an`*\\here.ps1")]
18+
[InlineData(@"C:\path\with[some]brackets\file.ps1", @"C:\path\with`[some`]brackets\file.ps1")]
19+
[InlineData(@"C:\look\an*\here.ps1", @"C:\look\an`*\here.ps1")]
2020
[InlineData("/Users/me/Documents/?here.ps1", "/Users/me/Documents/`?here.ps1")]
2121
[InlineData("/Brackets [and s]paces/path.ps1", "/Brackets `[and s`]paces/path.ps1")]
2222
[InlineData("/CJK.chars/脚本/hello.ps1", "/CJK.chars/脚本/hello.ps1")]
2323
[InlineData("/CJK.chars/脚本/[hello].ps1", "/CJK.chars/脚本/`[hello`].ps1")]
24-
[InlineData("C:\\Animals\\утка\\quack.ps1", "C:\\Animals\\утка\\quack.ps1")]
25-
[InlineData("C:\\&nimals\\утка\\qu*ck?.ps1", "C:\\&nimals\\утка\\qu`*ck`?.ps1")]
24+
[InlineData(@"C:\Animals\утка\quack.ps1", @"C:\Animals\утка\quack.ps1")]
25+
[InlineData(@"C:\&nimals\утка\qu*ck?.ps1", @"C:\&nimals\утка\qu`*ck`?.ps1")]
2626
public void CorrectlyWildcardEscapesPathsNoSpaces(string unescapedPath, string escapedPath)
2727
{
2828
string extensionEscapedPath = PathUtils.WildcardEscapePath(unescapedPath);
@@ -33,17 +33,17 @@ public void CorrectlyWildcardEscapesPathsNoSpaces(string unescapedPath, string e
3333
[Theory]
3434
[InlineData("DebugTest.ps1", "DebugTest.ps1")]
3535
[InlineData("../../DebugTest.ps1", "../../DebugTest.ps1")]
36-
[InlineData("C:\\Users\\me\\Documents\\DebugTest.ps1", "C:\\Users\\me\\Documents\\DebugTest.ps1")]
36+
[InlineData(@"C:\Users\me\Documents\DebugTest.ps1", @"C:\Users\me\Documents\DebugTest.ps1")]
3737
[InlineData("/home/me/Documents/weird&folder/script.ps1", "/home/me/Documents/weird&folder/script.ps1")]
3838
[InlineData("./path/with some/spaces", "./path/with` some/spaces")]
39-
[InlineData("C:\\path\\with[some]brackets\\file.ps1", "C:\\path\\with`[some`]brackets\\file.ps1")]
40-
[InlineData("C:\\look\\an*\\here.ps1", "C:\\look\\an`*\\here.ps1")]
39+
[InlineData(@"C:\path\with[some]brackets\file.ps1", @"C:\path\with`[some`]brackets\file.ps1")]
40+
[InlineData(@"C:\look\an*\here.ps1", @"C:\look\an`*\here.ps1")]
4141
[InlineData("/Users/me/Documents/?here.ps1", "/Users/me/Documents/`?here.ps1")]
4242
[InlineData("/Brackets [and s]paces/path.ps1", "/Brackets` `[and` s`]paces/path.ps1")]
4343
[InlineData("/CJK chars/脚本/hello.ps1", "/CJK` chars/脚本/hello.ps1")]
4444
[InlineData("/CJK chars/脚本/[hello].ps1", "/CJK` chars/脚本/`[hello`].ps1")]
45-
[InlineData("C:\\Animal s\\утка\\quack.ps1", "C:\\Animal` s\\утка\\quack.ps1")]
46-
[InlineData("C:\\&nimals\\утка\\qu*ck?.ps1", "C:\\&nimals\\утка\\qu`*ck`?.ps1")]
45+
[InlineData(@"C:\Animal s\утка\quack.ps1", @"C:\Animal` s\утка\quack.ps1")]
46+
[InlineData(@"C:\&nimals\утка\qu*ck?.ps1", @"C:\&nimals\утка\qu`*ck`?.ps1")]
4747
public void CorrectlyWildcardEscapesPathsSpaces(string unescapedPath, string escapedPath)
4848
{
4949
string extensionEscapedPath = PathUtils.WildcardEscapePath(unescapedPath, escapeSpaces: true);

test/PowerShellEditorServices.Test/Session/PsesInternalHostTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ await psesHost.ExecutePSCommandAsync(
223223

224224
[Theory]
225225
[InlineData("")] // Regression test for "unset" path.
226-
[InlineData("C:\\Some\\Bad\\Directory")] // Non-existent directory.
226+
[InlineData(@"C:\Some\Bad\Directory")] // Non-existent directory.
227227
[InlineData("testhost.dll")] // Existent file.
228228
public async Task CanHandleBadInitialWorkingDirectory(string path)
229229
{

test/PowerShellEditorServices.Test/Session/ScriptFileTests.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -654,20 +654,21 @@ public void DocumentUriReturnsCorrectStringForAbsolutePath()
654654
scriptFile = new ScriptFile(DocumentUri.FromFileSystemPath(path), emptyStringReader, PowerShellVersion);
655655
Assert.Equal("file:///home/NaomiNagata/projects/Rocinate/Proto%3AMole%3Acule.ps1", scriptFile.DocumentUri);
656656

657-
path = "/home/JamesHolden/projects/Rocinate/Proto:Mole\\cule.ps1";
657+
path = @"/home/JamesHolden/projects/Rocinate/Proto:Mole\cule.ps1";
658658
scriptFile = new ScriptFile(DocumentUri.FromFileSystemPath(path), emptyStringReader, PowerShellVersion);
659659
Assert.Equal("file:///home/JamesHolden/projects/Rocinate/Proto%3AMole%5Ccule.ps1", scriptFile.DocumentUri);
660660
}
661661
}
662662

663663
[Trait("Category", "ScriptFile")]
664664
[Theory]
665-
[InlineData("C:\\Users\\me\\Documents\\test.ps1", false)]
665+
[InlineData(@"C:\Users\me\Documents\test.ps1", false)]
666666
[InlineData("/Users/me/Documents/test.ps1", false)]
667667
[InlineData("vscode-notebook-cell:/Users/me/Documents/test.ps1#0001", true)]
668668
[InlineData("https://microsoft.com", true)]
669669
[InlineData("Untitled:Untitled-1", true)]
670-
[InlineData("'a log statement' > 'c:\\Users\\me\\Documents\\test.txt'\r\n", false)]
670+
[InlineData(@"'a log statement' > 'c:\Users\me\Documents\test.txt'
671+
", false)]
671672
public void IsUntitledFileIsCorrect(string path, bool expected) => Assert.Equal(expected, ScriptFile.IsUntitledPath(path));
672673
}
673674
}

0 commit comments

Comments
 (0)