3

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

H H
  • 263,252
  • 30
  • 330
  • 514
Ols1
  • 321
  • 3
  • 15
  • 1
    In your test, `viewModel.SaveCommand.Execute(object parameter)`. Then, check your Model and see if you get the desired results. – Jake Berger Jun 07 '11 at 20:44

1 Answers1

5

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);
GazTheDestroyer
  • 20,722
  • 9
  • 70
  • 103