Skip to content

Commit c660094

Browse files
feat: added handling of failed addition of exclusive file stream to tracked state
1 parent 18716e4 commit c660094

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/TestableIO.System.IO.Abstractions.TestingHelpers/MockFileStream.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ public MockFileStream(
108108

109109
if (share is FileShare.None)
110110
{
111-
_fileShareNoneStreams.TryAdd(path, 0);
111+
if (!_fileShareNoneStreams.TryAdd(path, 0))
112+
{
113+
throw CommonExceptions.ProcessCannotAccessFileInUse(path);
114+
}
112115
}
113116
this.access = access;
114117
this.share = share;

0 commit comments

Comments
 (0)