views:

33

answers:

1

I'm trying to call an event from my mocked object. I'm doing it like:

importObject.Raise(x => x.RequestImportLevel += null, false, false, true, importLevel);

the last parameter required to be passed by reference. So, i'm getting an exception

Parameter #4 is System.Int16 but should be System.Int16&

What can I do to handle this?

If the problem is in Rhino Mocks - are there any other frameworks that cleanly support this out-of-the-box?

A: 

This object implemented an interface, so I just created a dummy class, make it inherit from IEventWithRefParameter and introduced a function like

    public virtual void RaiseRequestImportLevelEvent(bool hasYc, bool hasWc, bool hasDc, ref short chosenLevel)
    {
        if (RequestImportLevel != null)
        {
            RequestImportLevel(hasYc, hasWc, hasDc, ref chosenLevel);
        }
    }

Now I'm using an instance of this dummy class in my tests and when I'd like to raise an event I just call this function.

not nearly a clean solution, but at least it does the trick.

Shaddix