Describe the bug
I am upgrading from System.IO.Abstractions v17.0.18 to v19.2.29.
To Reproduce
usingSystem.IO;usingSystem.IO.Abstractions;usingSystem.IO.Abstractions.TestingHelpers;// ...[Test]publicasyncTaskFileSystemStreamBrokenTest(){varfileSystem=Substitute.For<IFileSystem>();varfileStream=System.IO.Abstractions.FileSystemStream.Null;fileSystem.File.OpenRead(default!).ReturnsForAnyArgs(fileStream);fileSystem.File.OpenRead("somePath");}This fails with an NSubsitute error though:

Also, Resharper suggests to simplify it in a way that it is essentially the same as this:
[Test]publicasyncTaskFileSystemStreamBrokenTest(){varfileSystem=Substitute.For<IFileSystem>();varfileStream=System.IO.Stream.Null;fileSystem.File.OpenRead(default!).ReturnsForAnyArgs(fileStream);fileSystem.File.OpenRead("somePath");}...which may explain why it fails.
Before all that I had a custom class for fileStream, which just also had the most common stuff implemented, so it was like your mock, except of the special type. Now the types don't match (I guess since v18.0.2) and as such I need to adapt it...
I tried this, too:
[Test]publicasyncTaskFileSystemStreamBrokenTest(){varfileSystem=Substitute.For<IFileSystem>();varfileStream=newMockFileStreamFactory(newMockFileSystem()).New("anything.example",FileMode.Open);fileSystem.File.OpenRead(default!).ReturnsForAnyArgs(fileStream);fileSystem.File.OpenRead("anything.example");}but that (kinda correctly) fails with:
System.IO.FileNotFoundException : Could not find file 'anything.example'.
....but I just wanna mock "any file", I don't care about what content etc.
Expected behavior
System.IO.Abstractions.FileSystemStream.Null should be useful as a wrapper, when you really don't care about your file handle/anything, but just want to mock it. I also don't wanr to mock a whole file system and provide any/all files in it, like I likely could with MockFileSystem.
Additional context
Finally found a workaround as . always exists:
[Test]publicasyncTaskFileSystemStreamBrokenTest(){varfileSystem=Substitute.For<IFileSystem>();varfileStream=newMockFileStreamFactory(newMockFileSystem()).New(".",FileMode.Open);fileSystem.File.OpenRead(default!).ReturnsForAnyArgs(fileStream);fileSystem.File.OpenRead(".");}IMHO there should be a more convenient way though.
System
<PackageReferenceInclude="System.IO.Abstractions"Version="19.2.29" />
<PackageReferenceInclude="System.IO.Abstractions.TestingHelpers"Version="19.2.29" />
and NSubstitute 4.4.0
Describe the bug
I am upgrading from System.IO.Abstractions v17.0.18 to v19.2.29.
To Reproduce
This fails with an NSubsitute error though:

Also, Resharper suggests to simplify it in a way that it is essentially the same as this:
...which may explain why it fails.
Before all that I had a custom class for
fileStream, which just also had the most common stuff implemented, so it was like your mock, except of the special type. Now the types don't match (I guess since v18.0.2) and as such I need to adapt it...I tried this, too:
but that (kinda correctly) fails with:
....but I just wanna mock "any file", I don't care about what content etc.
Expected behavior
System.IO.Abstractions.FileSystemStream.Nullshould be useful as a wrapper, when you really don't care about your file handle/anything, but just want to mock it. I also don't wanr to mock a whole file system and provide any/all files in it, like I likely could withMockFileSystem.Additional context
Finally found a workaround as
.always exists:IMHO there should be a more convenient way though.
System
and NSubstitute 4.4.0