开发者

How do I test Relaycommand?

开发者 https://www.devze.com 2023-02-12 19:30 出处:网络
I\'m reading this MSDN Article about MVVM. I\'m currently looking at the RelayCommand in figure #15. Pretend I wanted to test this SaveCommand. How开发者_运维技巧 would I do that? I\'m using NUnit and

I'm reading this

MSDN Article about MVVM. I'm currently looking at the RelayCommand in figure #15. Pretend I wanted to test this SaveCommand. How开发者_运维技巧 would I do that? I'm using NUnit and Rhino Mocks 3.6


RelayCommand is just another ICommand implementation, so to fire the command you just call Execute() on the relay command instance that is exposed by your viewmodel, and pass in any args.

Since the SaveCommand you mention takes no args you can fire it with:

MyViewModel.SaveCommand.Execute(null);
0

精彩评论

暂无评论...
验证码 换一张
取 消