views:

84

answers:

1

I am trying to unit test my ViewModel and my SaveItem(save, CanSave) delegate command. I want to ensure that CanSave is called and returns the correct value given certain conditions. Basically, how can I invoke the delegate command from my unit test, actually it's more of an integration test. Obviously I could just test the return value of the CanSave method but I am trying to use BDD to the letter, ie. no code without a test first.

A: 

Answered my own question. I just needed to RaiseCanExecuteChanged() in the properties that cause can execute to change (obviously), and then assert that the required outcome occurred ie that my object was not saved when CanExecute returned false.

Damian