Gab*_*aby 0 c# io file-io unit-testing
我正在使用System.IO.Abstractions编写一些单元测试,遵循GitHub中的示例代码并且卡在这里:
fileSystem: new FileSystem() //use default implementation which calls System.IO
Run Code Online (Sandbox Code Playgroud)
这行是为了初始化System.IO.FileSystem,但该类不存在...你知道它是否已被弃用或者我是否错了?
谢谢!
小智 5
是的,在生产代码中,你应该注入一个实例System.IO.Abstractions.FileSystem.在您的测试代码中的一个实例System.IO.Abstractions.TestingHelpers.MockFileSystem.