Two things...
1) If you're testing the provider you DON'T want to mock it. You'll
want to mock the things which IT uses. If on the other hand you're
testing your "Friends" code then yeah, mock the provider but you might
not need to mock the events. Just call the methods directly.
providerMock.Expect( p => p.RetrieveFriends() )
Friends target = new Friends(providerMock.Object)
target.GetFriends()
target.GetFriendsMethodComplete(null, new UserEventArgs(...))
2) I think you should be able to mock Events.
Just like properties are getting their own ExpectGet and ExpectSet
methods on the Mock<> object, it might be appropriate to add
ExpectAdd, ExpectRemove, RaiseEvent for event handlers?? RaiseEvent
would call all the added handlers.
providerMock.ExpectAdd( p => p.UserEventHandler ) <-- this captures
the added handler
providerMock.Expect( p => p.RetrieveFriends() )
Friends target = new Friends(providerMock.Object)
target.GetFriends()
providerMock.RaiseEvent( p => p.UserEventHandler, null, new
UserEventArgs(...) ) <-- this calls the captured handlers.