Commit fab80f9
authored
fix: Align MockDirectory and MockFile behavior with .NET's System.IO classes (#1190)
* fix: Align MockDirectory behavior with System.IO.Directory when deleting files
The MockDirectory class previously did not replicate the behavior of
System.IO.Directory when calling the Delete method on a file path. In
System.IO.Directory, an IOException is thrown if the specified path
points to a file instead of a directory.
This commit updates MockDirectory to ensure it throws an IOException in
this scenario, maintaining consistency with the expected behavior of
System.IO.Directory.
* fix: Align MockFile behavior with System.IO.File when deleting directories
The MockFile class previously did not replicate the behavior of
System.IO.File when calling the Delete method on a directory path. In
System.IO.File, an UnauthorizedAccessException is thrown if the
specified path points to a directory instead of a file.
This commit updates MockFile to ensure it throws an
UnauthorizedAccessException in this scenario, maintaining consistency
with the expected behavior of System.IO.File.1 parent 233b809 commit fab80f9
File tree
4 files changed
+43
-0
lines changed- src/TestableIO.System.IO.Abstractions.TestingHelpers
- tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests
4 files changed
+43
-0
lines changedLines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
161 | 167 | | |
162 | 168 | | |
163 | 169 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
234 | 239 | | |
235 | 240 | | |
236 | 241 | | |
| |||
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1018 | 1018 | | |
1019 | 1019 | | |
1020 | 1020 | | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
1021 | 1037 | | |
1022 | 1038 | | |
1023 | 1039 | | |
| |||
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
495 | 495 | | |
496 | 496 | | |
497 | 497 | | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
498 | 514 | | |
499 | 515 | | |
500 | 516 | | |
| |||
0 commit comments