Rhino MocksExtending the Mockable

time to read 1 min | 148 words

Well, thanks to Ivan Krivyakov, who did most of the work, this is now possible:

public void CanMockAppDomain()
	MockRepository mocks = new MockRepository();
	AppDomain appDomain = mocks.RemotingMock<AppDomain>();
	Assert.AreEqual(appDomain.BaseDirectory, "/home/user/ayende" );

As you can guess, this means that Rhino Mocks now also integrate with the Remoting infrastructure of the CLR. There are are quite a few types that inherit from MarshalByRefObject, and all of those are now mockable by Rhino Mocks.

I tried to compile a list of stuff that people wanted to mock but where unable to before, but the only thing that comes to mind is: System.Drawing.Graphics

The main benefit is if you want to mock WinForms stuff, since all of those inherit from MarshalByRefObject. Another interesting new mockable is System.IO.FileSystemWatcher.

The change is on the repository, but I am not making a release yet, I want to do some more testing first.

More posts in "Rhino Mocks" series:

  1. (30 Jun 2008) Getting closer to conclusion
  2. (29 Jun 2008) The role of Stub vs. Mock
  3. (29 Jun 2008) To be strict or not?