Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在阅读这篇关于 MVVM 的 MSDN 文章。我目前正在查看图 #15 中的 RelayCommand。假装我想测试这个 SaveCommand。我该怎么做?我正在使用 NUnit 和 Rhino Mocks 3.6
RelayCommand只是另一种ICommand实现,因此要触发您只需Execute()在视图模型公开的中继命令实例上调用的命令,并传入任何参数。
RelayCommand
ICommand
Execute()
由于您提到的 SaveCommand 不需要任何参数,因此您可以使用以下命令触发它:
MyViewModel.SaveCommand.Execute(null);