开发者

How can you unit test a DelegateCommand

I am trying to un开发者_高级运维it 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.


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜