You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add TempDirectory + string operator for combining paths
Only TempDirectory + relative string suffix is meaningful, since
TempFile.Path and TempDirectory.Path are both full paths. Combining
two full paths (or prepending to one) produces nonsense, so those
overloads are omitted.
A `TempDirectory` can be combined with a relative `string` suffix using the `+` operator. The directory path and suffix are joined with a single separator (an existing leading separator on the suffix is respected). The result is a `string`.
65
+
66
+
snippet: TempDirectoryAddOperator
67
+
68
+
62
69
### TempDirectory RootDirectory Property
63
70
64
71
Allows access to the root directory for all TempDirectory instances:
Copy file name to clipboardExpand all lines: docs/temp-directory.md
+27-5Lines changed: 27 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -146,6 +146,28 @@ public void InfoProperty()
146
146
<!-- endSnippet -->
147
147
148
148
149
+
### Combining paths
150
+
151
+
A `TempDirectory` can be combined with a relative `string` suffix using the `+` operator. The directory path and suffix are joined with a single separator (an existing leading separator on the suffix is respected). The result is a `string`.
152
+
153
+
<!-- snippet: TempDirectoryAddOperator -->
154
+
<aid='snippet-TempDirectoryAddOperator'></a>
155
+
```cs
156
+
[Fact]
157
+
publicvoidAddOperatorUsage()
158
+
{
159
+
usingvartemp=newTempDirectory();
160
+
161
+
// combine with a file name, joined by a single separator
162
+
varfilePath=temp+"test.txt";
163
+
164
+
File.WriteAllText(filePath, "content");
165
+
}
166
+
```
167
+
<sup><ahref='/src/Verify.Tests/TempDirectoryTests.cs#L280-L293'title='Snippet source file'>snippet source</a> | <ahref='#snippet-TempDirectoryAddOperator'title='Start of snippet'>anchor</a></sup>
168
+
<!-- endSnippet -->
169
+
170
+
149
171
### TempDirectory RootDirectory Property
150
172
151
173
Allows access to the root directory for all TempDirectory instances:
@@ -191,7 +213,7 @@ public void IgnoreLockedFiles()
191
213
Directory.Delete(path, true);
192
214
}
193
215
```
194
-
<sup><ahref='/src/Verify.Tests/TempDirectoryTests.cs#L340-L364'title='Snippet source file'>snippet source</a> | <ahref='#snippet-TempDirectoryIgnoreLockedFiles'title='Start of snippet'>anchor</a></sup>
216
+
<sup><ahref='/src/Verify.Tests/TempDirectoryTests.cs#L368-L392'title='Snippet source file'>snippet source</a> | <ahref='#snippet-TempDirectoryIgnoreLockedFiles'title='Start of snippet'>anchor</a></sup>
195
217
<!-- endSnippet -->
196
218
197
219
@@ -255,7 +277,7 @@ public async Task BuildPath()
255
277
});
256
278
}
257
279
```
258
-
<sup><ahref='/src/Verify.Tests/TempDirectoryTests.cs#L299-L319'title='Snippet source file'>snippet source</a> | <ahref='#snippet-TempDirectoryBuildPath'title='Start of snippet'>anchor</a></sup>
280
+
<sup><ahref='/src/Verify.Tests/TempDirectoryTests.cs#L327-L347'title='Snippet source file'>snippet source</a> | <ahref='#snippet-TempDirectoryBuildPath'title='Start of snippet'>anchor</a></sup>
259
281
<!-- endSnippet -->
260
282
261
283
@@ -277,7 +299,7 @@ public async Task Scrubbing()
277
299
});
278
300
}
279
301
```
280
-
<sup><ahref='/src/Verify.Tests/TempDirectoryTests.cs#L321-L336'title='Snippet source file'>snippet source</a> | <ahref='#snippet-TempDirectoryScrubbing'title='Start of snippet'>anchor</a></sup>
302
+
<sup><ahref='/src/Verify.Tests/TempDirectoryTests.cs#L349-L364'title='Snippet source file'>snippet source</a> | <ahref='#snippet-TempDirectoryScrubbing'title='Start of snippet'>anchor</a></sup>
281
303
<!-- endSnippet -->
282
304
283
305
Result:
@@ -322,7 +344,7 @@ public void NoUsing()
322
344
Debug.WriteLine(temp);
323
345
}
324
346
```
325
-
<sup><ahref='/src/Verify.Tests/TempDirectoryTests.cs#L282-L295'title='Snippet source file'>snippet source</a> | <ahref='#snippet-TempDirectoryNoUsing'title='Start of snippet'>anchor</a></sup>
347
+
<sup><ahref='/src/Verify.Tests/TempDirectoryTests.cs#L310-L323'title='Snippet source file'>snippet source</a> | <ahref='#snippet-TempDirectoryNoUsing'title='Start of snippet'>anchor</a></sup>
326
348
<!-- endSnippet -->
327
349
328
350
The directory can then be manually inspected.
@@ -346,7 +368,7 @@ public void OpenExplorerAndDebug()
346
368
temp.OpenExplorerAndDebug();
347
369
}
348
370
```
349
-
<sup><ahref='/src/Verify.Tests/TempDirectoryTests.cs#L267-L280'title='Snippet source file'>snippet source</a> | <ahref='#snippet-TempDirectoryOpenExplorerAndDebug'title='Start of snippet'>anchor</a></sup>
371
+
<sup><ahref='/src/Verify.Tests/TempDirectoryTests.cs#L295-L308'title='Snippet source file'>snippet source</a> | <ahref='#snippet-TempDirectoryOpenExplorerAndDebug'title='Start of snippet'>anchor</a></sup>
350
372
<!-- endSnippet -->
351
373
352
374
This method is designed to help debug tests by enabling the inspection of the contents of the temporary directory while the test is paused. It performs two actions:
0 commit comments