Hello,

im not able to raise events for a mocked interface defined in a .net
interop assembly (using vs2008 sp1, .net 2.0 sp2 and windows xp sp3).
If i try to raise an event on the mocked interface i'm facing a
exception informing me that "The last method call add_Click was not an
event add / remove method".

To give you an example.
    [Test]
    public void RhinoMocksInteropEventProblem_RaiseEvent_RaiseException
()
    {
      _CommandBarButtonEvents_Event foo =
MockRepository.GenerateStub<_CommandBarButtonEvents_Event>();
      foo.Raise(x => x.Click += null, null, null); // <---
System.InvalidOperationException : The last method call add_Click was
not an event add / remove method
    }

The _CommandBarButtonsEvents_Event interface is part of the Office
2003 PIA's (Primary Interop Assemblies). Please take a look at MSDN if
you need more information about the interface.

To my suprise, if i implement the interface in an abstract class and
mock the abstract class instead of the interface the code works.

  public abstract class Workaround : _CommandBarButtonEvents_Event
  {
    public abstract event _CommandBarButtonEvents_ClickEventHandler
Click;
  }

    [Test]
    public void RhinoMocksInteropEventProblem_RaiseEvent_Workaround()
    {
      _CommandBarButtonEvents_Event foo =
MockRepository.GenerateStub<Workaround>();
      foo.Raise(x => x.Click += null, null, null);
    }

So in my opinion this is a issue that RhinoMocks could handle better.
Has anyone faced the same limitation? Is this a known limitation of
RhinoMocks? Is there a better workaround?

Thanks in advance for any help.

Best regards,

Andreas Ländle

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/RhinoMocks?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to