Oren Eini

CEO of RavenDB

a NoSQL Open Source Document Database

Get in touch with me:

oren@ravendb.net +972 52-548-6969

Posts: 7,546
|
Comments: 51,163
Privacy Policy · Terms
filter by tags archive
time to read 1 min | 172 words

Okay, so Aaron Jensen has suggest an alternative syntax to this (which I don't like, since it has strings):

IEventRaiser loadRaiser = new EventRaiser((IMockedObject)mockedView, "Load");

It is this:

obj.Bar += EventRaiser.Raise(this, EventArgs.Empty);

Basically, it is reversing the syntax a bit, since it is actually the "register to event" syntax, but we can use that to raise events in a fairly natural way, without resorting to strings.

I am not sure if the sytnax is clear enough, so I wanted to ask, what would you rather have?

time to read 2 min | 376 words

One of the core principals of Rhino Mocks is "No Strings", and I have gone to great lengths in order to avoid using strings in Rhino Mocks. However, at one point you must stop and consider if this is really worth it. I believe that I have reached into the limits of what the language can do.

Here is how you can raise an event in Rhino Mocks today:

mockedView.Load += null;
IEventRaiser loadRaiser = LastCall.IgnoreArguments().GetEventRaiser();

No strings involved, and it is safe to use in the face of refactorying. However, it does create an expectatin that something will register to this event, but that is something that you want to happen anyway. Today I read this piece of code:

IEventRaiser loadRaiser = new EventRaiser((IMockedObject)mockedView, "Load");

I consider this a hack, because this is working around the way Rhino Mocks is supposed to work. Nevertheless, this is a valid use case if you don't want/care to know about event registration. In the case of a stub, you truly want to only get the event raiser, without the line noise of the version above.

So, in order to support this scenario without all the casting, you can now do this:

IEventRaiser loadRaiser = EventRaiser.Create(mockedView, "Load");

Just to make this clear, I don't really like this syntax, and I would recommend using the one above, but it is a valid request.

You can get it from the repository, or wait a few days until I make a release.

FUTURE POSTS

  1. Partial writes, IO_Uring and safety - one day from now
  2. Configuration values & Escape hatches - 4 days from now
  3. What happens when a sparse file allocation fails? - 6 days from now
  4. NTFS has an emergency stash of disk space - 8 days from now
  5. Challenge: Giving file system developer ulcer - 11 days from now

And 4 more posts are pending...

There are posts all the way to Feb 17, 2025

RECENT SERIES

  1. Challenge (77):
    20 Jan 2025 - What does this code do?
  2. Answer (13):
    22 Jan 2025 - What does this code do?
  3. Production post-mortem (2):
    17 Jan 2025 - Inspecting ourselves to death
  4. Performance discovery (2):
    10 Jan 2025 - IOPS vs. IOPS
View all series

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats
}