Skip to content

Conversation

@WestRyanK
Copy link
Contributor

The MockDirectory and MockFile classes previously did not replicate the .NET behavior of throwing exceptions in the following scenarios:

  • Attempting to delete a directory using MockFile.
  • Attempting to delete a file using MockDirectory.

This pull request addresses these inconsistencies by updating the mocks to correctly throw exceptions in these cases, ensuring their behavior aligns with the corresponding System.IO classes they are designed to mimic.

…ing 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.
…ories

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.
Copy link
Member

@vbreuss vbreuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @WestRyanK for this bugfix.

Looks good to me!

@vbreuss vbreuss merged commit fab80f9 into TestableIO:main Jan 25, 2025
9 checks passed
@github-actions
Copy link

This is addressed in release v21.2.8.

@github-actions github-actions bot added the state: released Issues that are released label Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state: released Issues that are released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants