testing events

Topics: Mobile Client Software Factory
Mar 27, 2007 at 9:05 PM
My application works fine, but when I try to implement a testing harness, using TestableRootWorkItem similar to the examples, I get a null refernece exception in 'SomeMethod()' at the 'MyEvent(...)' line.

The workitem looks much as I would expect, with the exception of there is no EventTopics in the collection. Do I need to do something in my testableworkitem to register the eventpublication? I have not been able to find any example code that tests events.

// -- In the presenter being tested --
...
EventPublication("topic://NRIS/MyEvent")
public event EventHandler MyEvent;
...
public someMethod()
{
...
MyEvent(this, new DataEventArgs<WorkItem>(WorkItem));
...
}
Mar 27, 2007 at 9:18 PM
>> public event EventHandler MyEvent;

This should read
public event EventHandler <DataEventArgs<WorkItem>> MyEvent

I am asking myself why you would be sending a workitem as a parameter. Can you elaborate?
Mar 27, 2007 at 10:43 PM
Hi thanks for the reply,
I'm sending the workitem in order to get at the Items container. What is the perfered way to access the workitem.items in the subscriber?

My main concern is the testing aspect; Do you have a recomendation where I might look in order to track down the null reference exception.


Allan wrote:
>> public event EventHandler MyEvent;

This should read
public event EventHandler <DataEventArgs<WorkItem>> MyEvent

I am asking myself why you would be sending a workitem as a parameter. Can you elaborate?