Skip to content

Conversation

@fgreinacher
Copy link
Contributor

Fixes #187
Supersedes #188

@fgreinacher
Copy link
Contributor Author

👀 anyone?

var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
{
{ sourceFilePath, new MockFileData(sourceFileContent) },
{ XFS.Path(@"c:\somethingelse\dummy.txt"), MockFileData.NullObject }
Copy link
Member

Choose a reason for hiding this comment

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

I think this test could be simplified a bit. The focus here is files, so we could probably just do something like C:\demo.txt, and drop the directory. There also more than likely isn't a need to include two files (I'm seeing dummy.txt and demo.txt). We just need to make sure the file gets from Point A to Point B. A rename of the file could achieve the same effect as moving directories.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, the second file was there to ensure the destination directory exists. I agree there was too much going on, so I'll simplify this as suggested. I won't rename the file because the focus of this test is the special behavior of MockDirectory.Move.


Assert.That(fileSystem.FileExists(destFilePath), Is.True);
Assert.That(fileSystem.GetFile(destFilePath).TextContents, Is.EqualTo(sourceFileContent));
Assert.That(fileSystem.FileExists(sourceFilePath), Is.False);
Copy link
Member

Choose a reason for hiding this comment

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

I'm usually against multiple asserts, but since this is more about state after a move, it seems OK. I had a slight issue with this because it was initially kinda confusing. Maybe we move the FileExists check to the top so we're validating state together? i.e. FileExists destFile (true) and FileExists sourceFile (false) need to be together to validate the file moved on the file system. The GetFile makes sure the source and dest were the same.

Copy link
Contributor Author

@fgreinacher fgreinacher Jan 27, 2019

Choose a reason for hiding this comment

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

Good catch, will reorder!


//if we're moving a file, not a directory, call the appropriate file moving function.
var fileData = mockFileDataAccessor.GetFile(fullSourcePath);
if (fileData != null && (fileData.Attributes & FileAttributes.Directory) == 0)
Copy link
Member

Choose a reason for hiding this comment

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

I think a safe navigation operator (?.) might simplify this conditional a little?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, changed this line to use safe navigation operator and Enum.HasFlag. Reads a lot easier now.

@jpreese
Copy link
Member

jpreese commented Jan 22, 2019

Overall I think it's fine, just a couple ease of understanding changes.

@fgreinacher
Copy link
Contributor Author

Feedback addressed with e74649d

@fgreinacher fgreinacher merged commit 19e1b6c into TestableIO:master Feb 7, 2019
fgreinacher added a commit that referenced this pull request Mar 10, 2019
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.

2 participants