79493275

Date: 2025-03-07 19:15:46
Score: 2.5
Natty:
Report link
var fileSystem = new System.IO.Abstractions.FileSystem();
// Mock System.IO.Abstractions's FileSystem
var mockFS = new Mock<FileSystem>();
var stream = fileSystem.File.Create("my file path.txt");
mockFS.Setup(x => x.File.OpenRead("my file path.txt")).Returns(stream);

Found this answer posted by Super Jade (A million thanks)

How do I create a FileSystemStream?

However, when I test the production code the instance is null. My file does exist at the filePath..

Reasons:
  • Blacklisted phrase (0.5): thanks
  • Blacklisted phrase (1): How do I
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: njdotnetdev