【发布时间】:2014-10-24 23:49:57
【问题描述】:
我正在为具有 DelegateCommand 的 ViewModel 编写单元测试。该命令使用异步方法执行,自 Prism 5 起支持如下:
MyCommand = new DelegateCommand(async () => await MyMethod());
现在我进行了单元测试,我注意到,
await model.Command.Execute();
Assert.IsTrue(model.CommandWasRun); // just an example
在命令运行时立即返回(因此失败)。
我认为这是一个错误的原因是,如果我写的话,在同一个单元测试中一切都很好
await model.MyMethod();
Assert.IsTrue(model.CommandWasRun);
是我遗漏了什么还是这是一个错误?
【问题讨论】:
标签: c# unit-testing async-await .net-4.5 prism-5