-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix file operations that fail when used with relative paths #407
Conversation
@@ -155,12 +155,12 @@ public void MockFile_Create_ShouldThrowDirectoryNotFoundExceptionIfCreatingAndPa | |||
{ | |||
// Arrange | |||
var fileSystem = new MockFileSystem(); | |||
var file = XFS.Path("C:\\path\\NotFound.ext"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test was not normalizing the path which caused test failures on Unix, so I fixed this.
|
||
// Assert | ||
Assert.IsFalse(fileSystem.Directory.Exists("C:\\path")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't belong in this test case so I decided to remove it.
@@ -249,14 +249,25 @@ public void MockFile_Open_ShouldThrowDirectoryNotFoundExceptionIfFileModeCreateA | |||
{ | |||
// Arrange | |||
var fileSystem = new MockFileSystem(); | |||
var file = XFS.Path("C:\\path\\NotFound.ext"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above
|
||
// Assert | ||
Assert.IsFalse(fileSystem.Directory.Exists("C:\\path")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above
@fgreinacher Looks good to me! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me, thanks @fgreinacher!
Root cause for the problems is wleader@95ead3a#diff-e76db4b13ed41e41943b80f8f1075287 where we started using
Path.GetDirectoryName
to get the parent directory, but unfortunately this method returns an empty string when the path does not contain directory information (e.g. a plain file name).The changes here make the paths absolute before passing them on to
Path.GetDirectoryName
.Fixes #404 and #401