有什么好的方法可以在单元测试和发布之间切换不同的上下文。在C#中
|
我在代码中有一些上下文可以切换,这取决于它是在测试中还是在发行中。
说我的产品编码:
PublishRequest(); // the real one
//PublishRequestPsudo(); // the one want to be run during unit test
我在想的方法是制作一个TestFlag类:
if (!TestFlag.PublishFlag)
{
PublishRequest();
}
else
{
PublishRequestPsudo();
}
如果我有很多地方这样做,这似乎很冗长。有什么好的模式吗?
没有找到相关结果
已邀请:
1 个回复
诞胃