When not using mocking, creating a filestream using FileMode.CreateNew throws an IOException when the target file already exists. However, the MockFileStream constructor behaves differently. When passing CreateNew as FileMode, it truncates the file. This causes issues for us in our unit tests, since the test scenario behaves differently than then real code.
When not using mocking, creating a filestream using FileMode.CreateNew throws an IOException when the target file already exists. However, the MockFileStream constructor behaves differently. When passing CreateNew as FileMode, it truncates the file. This causes issues for us in our unit tests, since the test scenario behaves differently than then real code.