Ols1
Ols1

Reputation: 321

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

Upvotes: 3

Views: 3096

Answers (1)

GazTheDestroyer
GazTheDestroyer

Reputation: 21251

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);

Upvotes: 5

Related Questions