Skip to content

Conversation

@fgreinacher
Copy link
Contributor

@fgreinacher fgreinacher commented Nov 27, 2018

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

@fgreinacher fgreinacher changed the title WIP: Add tests for file operations failing when used with relative paths WIP: Fix file operations that fail when used with relative paths Nov 27, 2018
@fgreinacher fgreinacher changed the title WIP: Fix file operations that fail when used with relative paths Fix file operations that fail when used with relative paths Nov 27, 2018
@fgreinacher
Copy link
Contributor Author

@rkoeninger @jpreese @robkeim 👀❓

{
// Arrange
var fileSystem = new MockFileSystem();
var file = XFS.Path("C:\\path\\NotFound.ext");
Copy link
Contributor Author

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.

TestDelegate action = () => fileSystem.File.Create(file);

// Assert
Assert.IsFalse(fileSystem.Directory.Exists("C:\\path"));
Copy link
Contributor Author

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.

{
// Arrange
var fileSystem = new MockFileSystem();
var file = XFS.Path("C:\\path\\NotFound.ext");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same comment as above

TestDelegate action = () => fileSystem.File.Open(file, FileMode.Create);

// Assert
Assert.IsFalse(fileSystem.Directory.Exists("C:\\path"));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same comment as above

@rkoeninger
Copy link
Contributor

@fgreinacher Looks good to me!

Copy link
Contributor

@robkeim robkeim left a 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!

@fgreinacher fgreinacher merged commit ec1b673 into TestableIO:master Nov 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants