﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>MHolmgren commented on Natural Event Syntax for Rhino Mocks</title><description>Any string syntax = The Horror! (use "some other" mocking framework)
  
Any code that looks like it is not raising an event when it is = No
  
  
Sorry for being a PIA, but readability is really high on my list.
</description><link>http://ayende.com/2588/natural-event-syntax-for-rhino-mocks#comment10</link><guid>http://ayende.com/2588/natural-event-syntax-for-rhino-mocks#comment10</guid><pubDate>Mon, 25 Jun 2007 07:47:33 GMT</pubDate></item><item><title>Jeff Brown commented on Natural Event Syntax for Rhino Mocks</title><description>I think this is pretty terrible and unintuitive syntax.  It looks like the EventRaiser is being attached to the event.  Of course it isn't.
  
  
What's wrong with something like this:
  
  
mockedView.Load += null; // don't actually add a handler
  
EventRaiser eventRaiser = LastCall.GetEventRaiser(); // but do get the raiser for it.
  
eventRaiser.Raise(...);
  
  
Or the shorthand:
  
  
mockedView.Load += null;
  
LastCall.RaiseEvent(...);
  
  
If it comes to it, I don't really mind the string version.  At least its intent is clear and free of side-effects.
  
  
Mocks.RaiseEvent(mockedView, "Load", ...);
</description><link>http://ayende.com/2588/natural-event-syntax-for-rhino-mocks#comment9</link><guid>http://ayende.com/2588/natural-event-syntax-for-rhino-mocks#comment9</guid><pubDate>Sun, 24 Jun 2007 01:23:52 GMT</pubDate></item><item><title>Simone commented on Natural Event Syntax for Rhino Mocks</title><description>I never tried using rhino mock with an event till now, I don’t know how it works now…
  
Don’t know if it’s feasible or not, but adding an event handler to the event you want to raise seems a bit confusing to me…
  
  
I know this uses strings:
  
IEventRaiser loadRaiser = new EventRaiser((IMockedObject)mockedView, "Load");
  
But in my opinion expresses better the intent that you want the mockedView to raise the Load event then writing
  
  
mockedView.Load += EventRaiser.Raise(this, EventArgs.Empty);
  
</description><link>http://ayende.com/2588/natural-event-syntax-for-rhino-mocks#comment8</link><guid>http://ayende.com/2588/natural-event-syntax-for-rhino-mocks#comment8</guid><pubDate>Sun, 24 Jun 2007 00:45:22 GMT</pubDate></item><item><title>Thomas Eyde commented on Natural Event Syntax for Rhino Mocks</title><description>I find it confusing that adding an event handler also will raise the event. We really wish that object members were real, first class objects, don't we?
  
  
How about:
  
  
withCustomEvents.MyEvent += delegate { myEventCalled = true; };
  
withCustomEvents.MyEvent += EventRaiser.Create(out handler);
  
handler.RaiseEvent();
  
  
Assert.IsTrue(myEventCalled);
  
  
I left out the default parameters to the event handler, as I usually don't need them.
</description><link>http://ayende.com/2588/natural-event-syntax-for-rhino-mocks#comment7</link><guid>http://ayende.com/2588/natural-event-syntax-for-rhino-mocks#comment7</guid><pubDate>Sun, 24 Jun 2007 00:01:36 GMT</pubDate></item><item><title>Ayende Rahien commented on Natural Event Syntax for Rhino Mocks</title><description>The problem is that this is not valid syntax. How do I get this to work?
</description><link>http://ayende.com/2588/natural-event-syntax-for-rhino-mocks#comment6</link><guid>http://ayende.com/2588/natural-event-syntax-for-rhino-mocks#comment6</guid><pubDate>Sat, 23 Jun 2007 23:49:55 GMT</pubDate></item><item><title>Simone Chiaretta commented on Natural Event Syntax for Rhino Mocks</title><description>I don't like that you have to register an event handler for the event in order to force the mockObject to raise that event.
  
It would have been great if it were possible to say EventRaiser.Raise(myEvent, myEventArgs), but you already said it's not.
  
  
And what about
  
EventRaiser.Create(mock, myEvent, myEventArgs)? is this possible?
</description><link>http://ayende.com/2588/natural-event-syntax-for-rhino-mocks#comment5</link><guid>http://ayende.com/2588/natural-event-syntax-for-rhino-mocks#comment5</guid><pubDate>Sat, 23 Jun 2007 22:29:42 GMT</pubDate></item><item><title>Roy Osherove commented on Natural Event Syntax for Rhino Mocks</title><description>the intent is very unclear and you have to be extra careful to make sure you "get" the fact that an event is actually being thrown..
</description><link>http://ayende.com/2588/natural-event-syntax-for-rhino-mocks#comment4</link><guid>http://ayende.com/2588/natural-event-syntax-for-rhino-mocks#comment4</guid><pubDate>Sat, 23 Jun 2007 19:42:28 GMT</pubDate></item><item><title>Ayende Rahien commented on Natural Event Syntax for Rhino Mocks</title><description>It isn't.
</description><link>http://ayende.com/2588/natural-event-syntax-for-rhino-mocks#comment3</link><guid>http://ayende.com/2588/natural-event-syntax-for-rhino-mocks#comment3</guid><pubDate>Sat, 23 Jun 2007 18:23:17 GMT</pubDate></item><item><title>Diego commented on Natural Event Syntax for Rhino Mocks</title><description>It´s great, but it will be prittier to me you write something like this:
  
  
EventRaiser.Raise(withCustomEvents.MyEvent);
  
  
Of couse, I don´t know if this way is posible..
  
</description><link>http://ayende.com/2588/natural-event-syntax-for-rhino-mocks#comment2</link><guid>http://ayende.com/2588/natural-event-syntax-for-rhino-mocks#comment2</guid><pubDate>Sat, 23 Jun 2007 18:21:46 GMT</pubDate></item><item><title>Ha commented on Natural Event Syntax for Rhino Mocks</title><description>This is definitely a tricky problem to solve. I think this syntax works. It'd be nice to be able to setup an expectation for the event being raised rather than having to attach the event twice, but I think what you have here works for me. :)
</description><link>http://ayende.com/2588/natural-event-syntax-for-rhino-mocks#comment1</link><guid>http://ayende.com/2588/natural-event-syntax-for-rhino-mocks#comment1</guid><pubDate>Sat, 23 Jun 2007 16:45:46 GMT</pubDate></item></channel></rss>