Natural Event Syntax for Rhino Mocks
I asked before, but didn't get any conclusive answers, what do you think about this syntax for raising events in Rhino Mocks. I spiked the implementation, and the code blow works. As I said, I don't like the awkward syntax of GetLastEventRaiser(), nor the reliance on EventRaiser.Create(mock, "Load"), because it relies on strings.
Does it make sense? Readable? Maintainable?
[Test] public void Raise_FromEventRaiser_RaiseTheEvent() { MockRepository mocks = new MockRepository(); IWithCustomEvents withCustomEvents = mocks.DynamicMock<IWithCustomEvents>(); mocks.ReplayAll(); bool myEventCalled = false; withCustomEvents.MyEvent += delegate { myEventCalled = true; }; withCustomEvents.MyEvent += EventRaiser.Raise(this, EventArgs.Empty); Assert.IsTrue(myEventCalled); }
I wanted to say that the implementation was simple, but it relies on emitting code at runtime, so is it simple?
Anyway, I am waiting for some additional responses

Comments
Comment preview