0

I currently have an event trigger firing a custom trigger action.

The action passes back a EventArgs type of object to the view's view-model.

This is all well and good when I run the code it works perfectly. However, when I come to test this portion of code it all goes a bit rubbish.

As stated We are using an MVVM type pattern so I'm testing the 'Doing' end of the event trigger in my view-model and what I want to do is create a 'mocked' EventArgs object to pass into the execute method of my command under test. However it requires a RoutedEvent as it's ID property as stated above and I don't have access to it's constructor!

Cannot Access Internal Constructor for 'RoutedEvent' here.

Has anyone got any ideas? The code converage in test is more important than the current implimentation so if this is thought to be 'untestable', then I can make changes.

tigerswithguitars
  • 2,497
  • 1
  • 31
  • 53
  • Could you add some sample code to show how all of this is wired up? It would help provide context to how you want to use Rhino.Mocks in the test. – PatrickSteele Jun 28 '11 at 16:08
  • I put rhino mocks in as a tag as I am currently using it to isolate some target classes for tests, so if it's needed I can. But if I don't have to I won't. I'll add an edit to the above that includes the some of the code. – tigerswithguitars Jun 30 '11 at 08:07

1 Answers1

0

I have answered my own Question I think.

Casting the object passed back from the view at an earlier point means that the object I am passing to the methods under test is more easily created.

This is what I have now for the method under test.

public void DoItemsChanged(IList param)

Before I had

public void DoItemsChanged(object param)

Where the param is a SelectedItemCollection (previously a RoutedEventArgs, but now I use the IvokeCommandAction on the event trigger in the view, passign the SelectedItems). The param is now more easily passed into the method for the test and the code it much more descriptive as well. So it's all good for everyone.

Community
  • 1
  • 1
tigerswithguitars
  • 2,497
  • 1
  • 31
  • 53