Describe the bug
FileAccess parameter in File.Open() is ignored when the FileMode is Create or CreateNew. Bug can be observed by checking the CanRead property of the returned Stream with FileAccess.ReadWrite.
To Reproduce
Below code snippet compares actual behavior to the mock:
var tempFile = Path.GetTempFileName();
using var fs = File.Open(tempFile, FileMode.Create);
Console.WriteLine(fs.CanRead);
var mock = new MockFileSystem();
var mockFile = mock.Path.GetTempFileName();
using var mockFs = mock.File.Open(mockFile, FileMode.Create);
Console.WriteLine(mockFs.CanRead);
Output:
Expected behavior
Mock behavior should match the .NET type.
Describe the bug
FileAccess parameter in File.Open() is ignored when the FileMode is Create or CreateNew. Bug can be observed by checking the
CanReadproperty of the returnedStreamwithFileAccess.ReadWrite.To Reproduce
Below code snippet compares actual behavior to the mock:
Output:
Expected behavior
Mock behavior should match the .NET type.