Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I test Relaycommand?

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

like image 387
Ols1 Avatar asked Dec 05 '25 23:12

Ols1


1 Answers

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);
like image 55
GazTheDestroyer Avatar answered Dec 08 '25 13:12

GazTheDestroyer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!