You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to be able to test a FileStream but I don't see anyway to do it with what it currently implemented. I see PR #177 but it hasn't been merged yet and the PR is 6 months old. I assume that FileStream is already covered in some way?
I was also looking to mock a FileStream and initially couldn't find how to mock a FileStream. See :
FileInfo.FromFileName(....). Here's a line from my code:
private readonly IFileSystem _fileSystem;
Constructor Inject into _fileSystem as usual.
FileStream fileStreamBack = null; using (fileStreamBack = (FileStream)_fileSystem.FileInfo.FromFileName(fileFrom).Open(FileMode.Open, FileAccess.Read)) using (var fileStreamf = (FileStream)_fileSystem.FileInfo.FromFileName(fileTo).Open(FileMode.Create, FileAccess.Write)) { fileStreamBack.CopyTo(fileStreamf); fileStreamBack.Flush(); // Making sure fileStreamBack.Close(); // Making sure }
Activity
bmcd77 commentedon Jun 29, 2017
I was also looking to mock a FileStream and initially couldn't find how to mock a FileStream. See :
FileInfo.FromFileName(....). Here's a line from my code:
private readonly IFileSystem _fileSystem;Constructor Inject into _fileSystem as usual.
FileStream fileStreamBack = null;using (fileStreamBack = (FileStream)_fileSystem.FileInfo.FromFileName(fileFrom).Open(FileMode.Open, FileAccess.Read))using (var fileStreamf = (FileStream)_fileSystem.FileInfo.FromFileName(fileTo).Open(FileMode.Create, FileAccess.Write)){fileStreamBack.CopyTo(fileStreamf);fileStreamBack.Flush(); // Making surefileStreamBack.Close(); // Making sure}jpreese commentedon Jul 11, 2018
To be resolved by #177
Add FileStreamFactory and support for mocking FileStreams (TestableIO…