EasyMock events

Help
Alexey
2006-10-30
2013-03-22
  • Alexey

    Alexey - 2006-10-30

    Hi!
    I tried EasyMockNET and it's very cool stuff, but how can I deal with events in EasyMockNET ?

    Example:
    I want to mock interface:
    ISomeInterface
    {
       void DoSomething();
       event DoCallback;
    }

    Now when a real object uses this mock my test fails with exception
    "Unexpected method call add_DoCallback(System.EventHandler`1 DataEventArgs`1):
    add_DoCallback(System.EventHandler`1 DataEventArgs`1): expected: 0, actual: 1".

    How can I aviod this ? How should I add expectations on events ?

     
    • Jon Skeet

      Jon Skeet - 2006-10-30

      Yes, add an expectation on an event by subscribing to it just as you'd call a method. Just think of += and -= as method calls - that's what they are, really.

      Jon

       

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks