stylecop 可以在单元测试中阻止 disk i/o 吗?

can stylecop prevent disk i/o in unit tests?

我希望我可以使用 stylecop 通过防止我定义的显式方法调用来防止单元测试中的磁盘 IO。

对 stylecop 的经验很少,但据我所知,它应该能够完成这种任务(防止给定的方法调用)。 搜索 Whosebug 和 google 没有成功。

这可能吗?如果可能,怎么做?

Stylecop 是一种用于监控代码以确保样式一致并引发构建警告/错误的工具。

我不相信它可以用来防止单元测试中的磁盘 IO。

来自 codeplex 上的旧 project home

StyleCop analyzes C# source code to enforce a set of style and consistency rules. It can be run from inside of Visual Studio or integrated into an MSBuild project. StyleCop has also been integrated into many third-party development tools.

Stylecop,不太可能,但您可以部分使用 Roslyn 规则(如果您的目标是 Visual Studio 2015)或 FxCop 规则(如果您的目标是 Visual Studio 2013)来实现此功能或更老)。

难以验证的情况是测试调用方法,调用方法,引发事件,导致 IO。测试调用访问 System.IO 的方法的更简单情况非常简单。