Rhino Mocks

Rhino Mocks, Github & Continuous Integration Builds

Well, it is official now, Rhino Mocks have a new home, and it is on github. We had a chance to try several common development scenarios with it, accepting patches & commits from other people, and so far I can tell you that I am very impressed with the Git style workflow. However, I know that many people aren’t comfortable with Git yet, so I decided to setup things to make things easier for everyone. You can now access the output of Rhino Mocks CI process here: http://builds.hibernatingrhinos.com/builds/Rhino-Mocks

posted @ Saturday, September 12, 2009 6:51 AM | Feedback (3)

Avé! Duci novo, similis duci seneci!

A while ago I was contacted by a friend who asked me if I am offering a commercial version of Rhino Mocks. That is not a mistake, he was working in a place where the use of Open Source Software was not allowed, and decided that the simplest way to use the tool was to go through the normal route, buy it. I wholeheartedly support this decision. :-) Considering how hard it is to make some organizations use Open Source projects, and how used those same organizations to buying software, it is probably the right decision....

posted @ Saturday, September 05, 2009 1:23 PM | Feedback (11)

Rhino Mocks 4.0 Planning Forum

It was brought up in the mailing list that we should have a more structured way of managing the ideas for Rhino Mocks 4.0, I agree, and the forum is here: http://nhprof.uservoice.com/pages/28152-rhino-mocks-4-0

posted @ Friday, September 04, 2009 5:20 PM | Feedback (2)

Planning for Rhino Mocks 4.0

Well, now that Rhino Mocks 3.6 is out of the way, we need to think about what the next version will look like. Initially, I thought to match Rhino Mocks 4.0 to the .NET 4.0 release and support mocking dynamic variables, but while this is still on the planning board, I think that it is much more important to stop and take a look at where Rhino Mocks is now and where we would like it to be. I started Rhino Mocks about 5 years ago, and the codebase has stood well in the test of time. There...

posted @ Thursday, September 03, 2009 6:45 PM | Feedback (34)

Rhino Mocks 3.6

This release is mostly to put out all the patches & fixes that went into Rhino Mocks since the 3.5 release, almost a year ago. The changes from the previous version are: Dynamic mocks and stubs will now assume that a call is match by any number of expectation. Recursive mocks (with help from webpaul) Fixing an issue with ArgManager in multi threaded scenarios (patch from Stefan Steinegger) Fixing problem with IgnoreArguments() after Do() erasing the Do() ...

posted @ Tuesday, September 01, 2009 1:13 PM | Feedback (16)

On PSake

James Kovacks introduced psake ( a power shell based build system )over a year ago, and at the time, I gave it a glance and decided that it was interesting, but not worth further investigation. This weekend, as I was restructuring my Rhino Tools project, I realized that I need to touch the build system as well. The Rhino Tools build system has been through several projects, and was originally ported from Hibernate. It is NAnt based, complex, and can do just about everything that you want expect be easily understandable. It became clear to me very quickly...

posted @ Sunday, August 30, 2009 3:02 PM | Feedback (27)

The complexity of unity

This post is about the Rhino Tools project. It has been running for a long time now, over 5 years, and amassed quite a few projects in it. I really like the codebase in the projects in Rhino Tools, but secondary aspects has been creeping in that made managing the project harder. In particular, putting all the projects in a single repository made it easy, far too easy. Projects had an easy time taking dependencies that they shouldn’t, and the entire build process was… complex, to say the least. I have been somewhat unhappily tolerant of this so...

posted @ Sunday, August 30, 2009 11:14 AM | Feedback (12)

Rhino Mocks 3.5 – Silverlight

This is an alpha release only, because I don’t do anything with Silverlight. Gunther Meyer ported Rhino Mocks to Silverlight, and now you can get the bits here.

posted @ Wednesday, February 04, 2009 1:30 PM | Feedback (2)

KB957541 available for direct download

This is the fix for the ExecutionEngineException that appeared in .Net 3.5 SP1, and was found by Rhino Mocks. You can get it here: http://support.microsoft.com/?id=957541

posted @ Wednesday, December 17, 2008 3:54 AM | Feedback (2)

Broad Support, indeed

posted @ Friday, November 14, 2008 12:44 AM | Feedback (2)

Recursive Mocking

This now works :-) The challenge is still open, I intentionally stopped before completing the feature, and there is a failing test in the RecusriveMocks fixture that you can start from. And just to give you an idea about what I am talking about, please run this and examine the results: svn diff https://rhino-tools.svn.sourceforge.net/svnroot/rhino-tools/trunk -r 1682:1683 A really cool web view of them is here.

posted @ Friday, October 10, 2008 1:40 PM | Feedback (17)

Request for comments: Changing the way dynamic mocks behave in Rhino Mocks

I have just committed a change to the way Rhino Mocks handles expectations for dynamic mocks and stubs.  Previously, the meaning of this statement was "expect Foo() to be called once and return 1 when it does": Expect.Call( bar.Foo ).Return(1); Now, the meaning of this is: "expect Foo() to be called one or more times, and return 1 when it does". This means that this will work: Assert.AreEqual(1, bar.Foo); Assert.AreEqual(1, bar.Foo); Assert.AreEqual(1, bar.Foo); Where as previously, using dynamic mocks, it would fail on the second assert, because the expectation that was setup was consumed. I think that this is a more natural way to...

posted @ Friday, October 10, 2008 12:42 PM | Feedback (23)

Rhino Mocks 3.5 Gems - Explicit Property Setting Expectations

This post is derived from the Rhino Mocks 3.5 documentation. Setting expectations for property set was always very simple, and slightly confusing with Rhino Mocks. Here is how you do it: view.Username = "the user name"; The problem is that it is hard to see that there is an expectation created here. So, with the generous help of Sebastian Jancke, we have a new syntax: Expect.Call(view.Username).SetPropertyWithArguments("the user name"); This is much more explicit and easier to understand. We can also set expectation on the property set, without expecting a certain value using this syntax: Expect.Call(view.Username).SetPropertyAndIgnoreArguments();

posted @ Thursday, October 09, 2008 9:48 AM | Feedback (3)

Rhino Mocks Challenge: Implement This Feature

Okay, let us see if this approach works... Here is a description of a feature that I would like to have in Rhino Mocks (modeled after a new feature in Type Mock). I don't consider this a complicated feature, and I would like to get more involvement from the community in building Rhino Mocks (see the list of all the people that helped get Rhino Mocks 3.5 out the door). The feature is fluent mocks. The idea is that this code should work: var mockService = MockRespository.GenerateMock<IMyService>(); Expect.Call( mockService.Identity.Name ).Return("foo"); Assert.AreEqual("foo", mockService.Identity.Name); Where identity is an interface. The best place to...

posted @ Wednesday, October 08, 2008 12:41 AM | Feedback (16)

Rhino Mocks 3.5 RTM

Today I decided that I had enough time to get bugs for the 3.5 RC, so I fixed all the remaining bugs, updated the Rhino Mocks 3.5 Documentation, and put the binaries out the site. For this release, I actually have 4 binary packages. One for .NET 3.5 and one for .NET 2.0, but I have an additional criteria, with the castle assemblies merged (default) and with the castle assemblies included). The reason for having those two options is that people who want to extend Rhino Mocks directly can do it more easily. In general, I suggest using the merged version. So,...

posted @ Sunday, October 05, 2008 12:49 AM | Feedback (14)

How .Net 3.5 SP1 broke Rhino Mocks

Okay, now that we are over the sensationalist headline, the actual problem is more complex than that. Let us assume that we have the following interface: public interface IComplexGeneric<T>{ void GenericMethod<K>();} Up until .Net 3.5 SP1, Rhino Mocks was perfectly happy to deal with such an interface (well, not happy, exactly, that requires some hard core code). With .Net 3.5 SP1, this generate an Execution Engine Exception. Fabian Schmied was kind enough to prove that select is broken here. This is the connect site issue, and I would appreciate it if you can vote for it. The work around for this would mean that...

posted @ Wednesday, August 13, 2008 5:15 PM | Feedback (22)

Mocking the file system

I have the following piece of code: And I wasn't sure about how I can test this thing. For production, this will use a File Stream, and getting those to produce errors is non trivial in most situations. A bit of thinking, however, told me that I can write a test for the error handling section of this fairly easily, like this:   I love having powerful tools at my reach.

posted @ Sunday, July 27, 2008 5:07 AM | Feedback (2)

Beautiful (nontrivial) Code - Rhino Mocks 3.5's AssertWasCalled

Beautiful code is not something that is easy to define. I think of this as something that is extremely elegant, that solve a hard problem in a way that isn't brute force. I think that the way Rhino Mocks implements the AssertWasCalled functionality is elegant, and I would like to point it out. I know of at least one contributor to Rhino Mocks who consider that piece of code scary, by the way, so it is not cut & dry. Here is the actual method call: public static void AssertWasCalled<T>(this T mock, Action<T>...

posted @ Sunday, July 13, 2008 12:02 PM | Feedback (6)

Where mocking fails

I mentioned before that Rhino Mocks is a very powerful framework. This can be a problem at times, because it make it hard to notice that you cross the line into mock abuse. Let us look at this test for example: [Test] public void Will_raise_message_arrived_event_for_each_message_in_batch_and_across_batches() { var stubbedIncomingMessageRepository = MockRepository.GenerateStub<IIncomingMessageRepository>(); var queue = new Queue(new Uri("queue://localhost/testQueue"), MockRepository.GenerateStub<IOutgoingMessageRepository>(), stubbedIncomingMessageRepository); var msgQueue = new Queue<QueueMessage>(); stubbedIncomingMessageRepository .Stub(x => x.GetEarliestMessage()) .Return(null) .Do(invocation => { lock (msgQueue) { invocation.ReturnValue = msgQueue.Count == 0 ? null : msgQueue.Dequeue(); } }) .Repeat.Any(); stubbedIncomingMessageRepository .Stub(x => x.Transaction(Arg<Action>.Is.Anything)) .Do(invocation => ((Action) invocation.Arguments[0])()) .Repeat.Any(); ; stubbedIncomingMessageRepository .Stub(x => x.Save(Arg<QueueMessage>.Is.Anything)) .Do(invocation => { lock (msgQueue) { msgQueue.Enqueue((QueueMessage)invocation.Arguments[0]); } }) .Repeat.Any(); var callCount = 0; var e = new ManualResetEvent(false); queue.MessageArrived += (obj => { if (Interlocked.Increment(ref callCount) >=...

posted @ Wednesday, July 02, 2008 10:52 PM | Feedback (1)

Advance Mocking with Rhino Mocks 3.5

Here is why I love Rhino Mocks. This is a test that utilize quite a bit of the underlying power of Rhino Mocks. Check this out: [Test] public void For_each_batch_from_repository_will_create_and_execute_command() { var stubbedCommand = MockRepository.GenerateMock<ICommand>(); var mocks = new MockRepository(); var queueProcessor = mocks.PartialMock<QueueProcessor>( stubbedQueueFactory, stubbedOutgoingMessageRepository); queueProcessor .Stub(x => x.CreateCommand(Arg<SingleDestinationMessageBatch>.Is.Anything)) .Return(stubbedCommand) .Repeat.Any(); stubbedCommand.Expect(x => x.Execute()).Repeat.Times(3); mocks.ReplayAll(); stubbedOutgoingMessageRepository .Stub(x => x.GetBatchOfMessagesToSend()) .Return(new MessageBatch { DestinationBatches = new[] { new SingleDestinationMessageBatch(), new SingleDestinationMessageBatch(), new SingleDestinationMessageBatch(), } }); stubbedOutgoingMessageRepository .Stub(x => x.GetBatchOfMessagesToSend()) .Return(new MessageBatch()) .Do(delegate { queueProcessor.Stop(); }); queueProcessor.Run(); stubbedCommand.VerifyAllExpectations(); } I use a partial mock to override a single method, use AAA for really nice syntax, the new Do() to allow me to have fine grain control over what is going on and in general mess about with complete...

posted @ Wednesday, July 02, 2008 8:26 AM | Feedback (5)

Rhino Mocks 3.5: A feature to be proud of - seamless Do()

One of the major pain points for me in Rhino Mocks has always been the Callback() and Do() delegates. I designed them at the 1.1 days, when we didn't have such things as anonymous delegates or lambda. As a result, they required you to explicitly pass a delegate type, where a pain to use and major eye sore. For a long time, I accepted that there is nothing to do. The fault was with the annoying compiler, and like many other language limitations, you just have to live with it. I was writing something today and I...

posted @ Wednesday, July 02, 2008 8:17 AM | Feedback (12)

Rhino Mocks 3.5 RC 1 Refresh

Somehow I managed to release the wrong version when I released RC 1. I missed a few patches that I thought were it and weren't. No idea how this happened, but there is a new refresh builds here. Note that those do not contain the new API discussed here, they are just refreshed version of RC 1.

posted @ Tuesday, July 01, 2008 3:41 AM | Feedback (0)

Rhino Mocks 3.5 Design Decisions: Getting closer to conclusion

There has been an invaluable amount of discussion regarding the question I pose about the API design of Rhino Mocks 3.5. Jeremy Gray in particular has been helpful in making good suggestions and making the argument to simplify the API for developers who are not experts in TDD terminology and usage. My current thinking is to combine GenerateMock() and GenerateStub() into a single method, GenerateTestDouble(). This method will return a dynamic mock. If you want a true stub, you will be able to call myTestDouble.StubUnexpectedInteractions(). Note, since stubs have a special behavior for properties, I am also considering:...

posted @ Monday, June 30, 2008 8:29 PM | Feedback (35)

Rhino Mocks 3.5 Design Decisions: The role of Stub vs. Mock

Let us say that we have the following code that we want to test: public void ForgotMyPassword(string username) { var user = users.GetUserByName(username); user.HashedPassword = "new pass"; users.Save(user); } One way to write the test is: public void When_user_forgot_password_should_save_user() { var mockUserRepository = MockRepository.GenerateMock<IUserRepository>(); var stubbedSmsSender = MockRepository.GenerateStub<ISmsSender>(); var theUser = new User{HashedPassword = "this is not hashed password"}; mockUserRepository.Stub(x => x.GetUserByName("ayende")).Return(theUser); mockUserRepository.Expect( x => x.Save(theUser) ); var controllerUnderTest = new...

posted @ Sunday, June 29, 2008 4:55 AM | Feedback (26)

Rhino Mocks 3.5 Design Decisions: To be strict or not?

Here is an interesting problem. What should this piece of code do? var stubSmsSender = MockRepository.GenerateStub<ISmsSender>(); // test code stubSmsSender.VerifyAllExpectations(); Right now this is a no-op. But since stubs are explicitly not mocks, they shouldn't be verified. Should I throw here? For something which is a test design decision?

posted @ Sunday, June 29, 2008 4:46 AM | Feedback (12)

Rhino Mocks 3.5 Release Candidate

Well, after a much longer beta period, and getting some very valuable input, Rhino Mocks 3.5 is out in Release Candidate. I am putting this out as RC, but I am pretty sure that those bits would be the RTM version as well. The only major task left is to start documenting the changes. The move to 3.5 has made a lot changes in approach that I recommend to use (note that the API is compatible with 3.4). I would like to thank Jordan Terrell, David Tchepak, Stefan Steinegger, Jason Meckley, Scott Brady, Ernst Naezer, Roelof Blom and...

posted @ Sunday, June 29, 2008 4:02 AM | Feedback (6)

The test of fire: Rhino Mocks 3.5 in the real world

I have been waiting on the release for Rhino Mocks 3.5, seeing what kind of feedback I can get from users. I also had another reason, I hadn't had the chance to really give it a good testing, in the only manner that matter, using it to develop production ready software. Here is my latest test, which I am fairly pleased with. [TestFixture] public class WebcastControllerTest { private WebcastController controller; private IRepository<Webcast> repositoryStub; private StubEngineContext engineContext; private IUnitOfWork unitOfWorkStub; private IDisposable disposeGlobalUnitOfWorkRegistration; [SetUp] public void Setup() { repositoryStub = MockRepository.GenerateStub<IRepository<Webcast>>(); unitOfWorkStub = MockRepository.GenerateStub<IUnitOfWork>(); controller = new WebcastController(repositoryStub) ...

posted @ Friday, June 13, 2008 12:49 AM | Feedback (7)

Challenge: Striving for better syntax

Or, as I like to call them, yes another stupid language limitation. I did some work today on Rhino Mocks, and after being immersed for so long in DSL land, I had a rude awakening when I remembered just how much inflexible the C# language is. Case in point, I have the following interface: public interface IDuckPond { Duck GetDuckById(int id); Duck GetDuckByNameAndQuack(string name, Quack q); } I want to get to a situation where the following will compile successfully: IDuckPond pond = null; pond.Stub( x => x.GetDuckById ); pond.Stub( x => x.GetDuckByNameAndQuack ); Any ideas? Note that unlike my other challenges, I...

posted @ Tuesday, May 27, 2008 7:13 PM | Feedback (28)

Compare and contrast: Rhino Mocks vs. Hand Rolled Stubs

For various reasons which will be made clear soon, I needed to write the same test twice, once using Rhino Mocks, the second time using hand rolled stubs. I thought it was an interesting exercise, since this is not demo level code. [Test] public void WillCallHandlesWithWithRouteTestHanlderWhenRouteCalled_UsingRhinoMocks() { const IQuackFu msg = null; var mocks = new MockRepository(); var routing = dslFactory.Create<RoutingBase>(@"Routing\simple.boo"); var mockedRouting = (RoutingBase)mocks.PartialMock(routing.GetType()); Expect.Call(() => mockedRouting.HandleWith(null, null)) .Constraints(Is.Equal(typeof(RoutingTestHandler)), Is.Anything()); mocks.ReplayAll(); mockedRouting.Initialize(msg); mockedRouting.Route(); mocks.VerifyAll(); } [Test] public void WillCallHandlesWithWithRouteTestHanlderWhenRouteCalled() { const IQuackFu msg = null; dslFactory.Register<StubbedRoutingBase>(new StubbedRoutingDslEngine()); var routing = dslFactory.Create<StubbedRoutingBase>(@"Routing\simple.boo"); routing.Initialize(msg); routing.Route(); Assert.AreEqual(typeof (RoutingTestHandler), routing.HandlerType); Assert.IsInstanceOfType( typeof(NewOrderMessage), routing.Transformer() ); }

posted @ Tuesday, May 20, 2008 8:02 PM | Feedback (0)

Would I add static mocking to Rhino Mocks?

Eli Lopian joined the discussion about Mocks, Statics and the automatic rejection some people have of Type Mock and its capabilities. Here is the deal. I don't like the idea of mocking statics. Given a patch that would add this capability to Rhino Mocks *, I would apply it in a heartbeat. Hm... that seems inconsistent of me... Leaving aside the fact that I feel no urging need to be internally consistent, I don't have an issue with the feature itself. Mocking statics is not inherently bad....

posted @ Tuesday, May 20, 2008 12:44 AM | Feedback (5)

Rhino Mocks 3.5 Beta Released

3 Months ago I released Rhino Mocks 3.4, we have made some great improvement to Rhino Mocks in the meantime, and it is time for a new release. I generally don't believe in beta releases for Rhino Mocks, but this time we are coming up with a new syntax, and I want to get additional external input before we make a final release on that. The biggest new feature is the new AAA syntax, which you can read about in the relevant post, but we had a few other new things as well. CreateMock() is...

posted @ Friday, May 16, 2008 3:50 PM | Feedback (5)

Rhino Mocks - Arrange, Act, Assert Syntax

I intend to release the new version of Rhino Mocks soon, and I wanted to show the new syntax that I have been working on. I still need to write more thorough documentation, but I think that just the syntax should be a pretty good indication of how things are going. Without further ado, here is the code: [Test] public void WhenUserForgetPasswordWillSendNotification_WithConstraints() { var userRepository = MockRepository.GenerateStub<IUserRepository>(); var notificationSender = MockRepository.GenerateStub<INotificationSender>(); userRepository.Stub(x => x.GetUserById(5)).Return(new User { Id = 5, Name = "ayende" }); new LoginController(userRepository,...

posted @ Friday, May 16, 2008 3:34 PM | Feedback (22)

Rhino Mocks new feature: Persistent Mock Repository

Here is something that most people just don't think about, but it hits some people at the high end. Rhino Mocks is extremely efficient mocking framework, for just about any scenario. However, when it comes the time to mock large amount of interfaces (where large is in the hundreds to thousands), or if you have large interfaces (with dozens or hundreds of methods), it is costly to create the mocks. Rhino Mocks does some caching internally, but it is noticeable issue to some people. We are talking about an extra second or two for even most pathological cases here,...

posted @ Sunday, May 04, 2008 2:02 AM | Feedback (0)

On API Design

Krzysztof points out that Rhino Mocks has 26(!) methods to create various mocks. I was very surprised to hear that, so I took a look, and he is right. The problem is how you think about those. Those 26 methods are only applicable when you count each overload as a separate method. Without counting the overloads, we have 10 methods. Then we have to consider options. In Rhino Mocks, you tend to have the following options: Create mock, create mock with remoting, create mock from multiple types. That works to reduce the amount of options that we have down to about 4...

posted @ Monday, April 21, 2008 7:34 PM | Feedback (7)

Rhino Mocks Futures

I have been thinking about this for a while now, and I am getting ready to release Rhino Mocks 3.5. The major feature is taking advantage on C# 3.0 language features. This allow some really interesting experimentation. var mockedSmsSender = mocks.ToBeNamedMocked<ISmsSender>(); var mockedRepository = mocks.ToBeNamedMocked<IUserRepository>(); mockedRepository.Stub( x=> x.GetUserByName("ayende") ).Return( new User{Name="ayende", Pass="1234"}); new LoginController(mockedSmsSender, mockedRepository ).ForgotYourPassword("ayende"); mockedSmsSender.Verify( x => x.Send("ayende, your pass is 1234"); A few things to note about this code. No explicit record / replay model Arrange Act Assert model You can setup return values by using...

posted @ Sunday, April 20, 2008 6:11 PM | Feedback (23)

Advance Mocking - Partial mocks and Do()

Kyle has just posted about the MvcContrib.TestHelper project: The CreateController method on my TestControllerBuilder uses Castle's DynamicProxy to create the controller. It also creates a ControllerContext using dynamic mocks from Rhino Mocks similar to the way Haackselman have already showed you and wires it up to the controller. An interceptor is also attached to the controller to intercept calls to RenderView and RedirectToAction. (Actually, it intercepts all calls but only these two have special handling.) Calls to either method will populate an appropriate object on the builder class. In the example above, I'm using the RedirectToActionData object. I'll leave...

posted @ Wednesday, March 19, 2008 7:39 PM | Feedback (4)

Planning Rhino Mock 3.5 - The Lambda Edition

Note, this is a copy of the discussion that is taking place in the Rhino Mocks mailing list. Now that I pushed all the current changes out, we need to start thinking about the next version. I am planning on seeing what kind of syntax I can get from the language using C# 3.0. As of yet, I don't have any concrete ideas about what should be done, so I am here to solicit ideas about what you want. Syntax suggestions, patches, comments, etc are all welcome.

posted @ Monday, February 18, 2008 11:55 AM | Feedback (3)

Rhino Mocks 3.4 Released

Well, it is about that time again, I got enough changes to make a release worthwhile. It has been almost five months, and we got a whole bunch of stuff going on, including a lot of stuff from contributors. (Take that, one man project :-) ). As usual, you can get it here and the source is available here. It is interesting to note that a lot of people have stuck with Rhino Mocks 3.1, I guess that there is really no need to upgrade, if you get what you want... Features, more features, glorious features! Added CreateMockWithRemoting and...

posted @ Monday, February 18, 2008 11:50 AM | Feedback (10)

Mutli Mocks and verifying behavior

I have the following piece of code: protected override void DoClose() { IDisposable dispoable = enumerator as IDisposable; if (dispoable != null) dispoable.Dispose(); dispoable = enumerable as IDisposable; if(dispoable != null) dispoable.Dispose(); } How do I verify that it correctly disposes both enumerator and enumerable when the method is called? Here is the test that I wrote, it is using Rhino Mocks' Multi Mocks feature to generate a proxy that has more than a single implementation. [Test] public void WillDisposeInternalEnumeratorAndEnumerableWhenDisposed() { ...

posted @ Saturday, January 05, 2008 6:21 PM | Feedback (3)

The Record/Replay/Verify model

Daniel and I are having an interesting discussion about mock frameworks, and he just posted this: What's wrong with the Record/Reply/Verify model for mocking frameworks. Daniel also pulled this quote from the Rhino Mocks documentation: Record & Replay model - a model that allows for recording actions on a mock object and then replaying and verifying them. All mocking frameworks uses this model. Some (NMock, TypeMock.Net, NMock2) use it implicitly and some (EasyMock.Net, Rhino Mocks) use it explicitly. Daniel go on to say: I find this record/replay/verify model somewhat unnatural. I suggest that you would read the entire...

posted @ Wednesday, December 26, 2007 11:45 PM | Feedback (7)

Moq: Mocking in C# 3.0

Daniel has a very interesting post about how mocking can works in C# 3.0 (I don't like the term Linq for Mock, if you haven't noticed). I wonder if he has used Rhino Mocks, from the description of mock frameworks in the post, it looks like he didn't. At any rate, the syntax that he has there if quite interesting: var mock = new Mock<IFoo>();mock.Expect(x => x.DoInt(It.Is<int>(i => i % 2 == 0))).Returns(1); The use of lambda as a way to specify expectations is cool, and as a way to specify constraints, flat out amazing. You can do most of that with Rhino...

posted @ Wednesday, December 19, 2007 8:00 AM | Feedback (36)

Don't like visibility levels, change that

This came up with respect to MS MVC. The MS MVC team has decided to make some methods protected, and that makes testing using Rhino Mocks a bit of a pain. Let us assume that I want test that the call to ProductController.Index() will render the "index.aspx" view. I can do something like: [Test] public void ShouldAskToRenderTheIndexAspxView() { MockRepository mocks = new MockRepository(); ProductController controller = mocks.PartialMock<ProductController>(); using(mocks.Record()) { controller.RenderView("index.aspx"); // <<-- Compiler error here, RenderView is protected! } using (mocks.Playback()) { controller.Index(); } } Problem, part of the Rhino Mocks design goal was the use of the compiler and tools as verifiers. I explicitly do not want to have strings in my code,...

posted @ Thursday, December 13, 2007 10:16 AM | Feedback (9)

Order in the mocking!

Consider this little tidbit: MockRepository mocks = new MockRepository(); ICustomer customer = mocks.CreateMock<ICustomer>(); using (mocks.Record()) using (mocks.Ordered()) { Expect.Call(customer.Id).Return(0); customer.IsPreferred = true; } using (mocks.Playback()) { customer.IsPreferred = true; } What would you expect would be the result of this code? Well, it should obviously fail, right? And probably give a message to the effect of unordered method call. Well, it does fail, but it gives the usual message, not talking about ordered method calls at all. The error message is misleading, what was going on? I wonder if I am going to bore someone with this description, but what the hell, you can always skip ahead. Rhino Mocks records all expectations in a...

posted @ Thursday, November 15, 2007 4:18 AM | Feedback (1)

Using Expect.Call( void method )

It looks like there is some confusion about the way Rhino Mocks 3.3 Expect.Call support for void method works. Let us examine this support for an instance, shall we? Here is all the code for this feature: public delegate void Action(); public static IMethodOptions<Action> Call(Action actionToExecute) { if (actionToExecute == null) throw new ArgumentNullException("actionToExecute", "The action to execute cannot be null"); actionToExecute(); return LastCall.GetOptions<Action>(); } As you can see, this is simply a method that accept a no args delegate, execute it, and then return the LastCall options. It is syntactic sugar over the usual "call void method and then call LastCall). The important concept here is to...

posted @ Saturday, October 27, 2007 12:29 PM | Feedback (20)

Rhino Mocks 3.3

Well, it has been a couple of months, but we have a new release of Rhino Mocks. I would like to thank Aaron Jensen, Ivan Krivyakov and Mike Winburn for contributing. Probably the two big new features is the ability to call void methods using Expect.Call and the ability to use remoting proxies to mock classes that inherit from MarshalByRefObject. Rhino Mocks will now choose the appropriate mocking strategy based on the type you want. Note: you cannot pass constructor arguments or create partial mocks with remoting proxies. The change log is: Bug Fixes:  Fixing...

posted @ Friday, October 26, 2007 1:42 AM | Feedback (8)

Rhino Mocks: Void methods using Expect.Call

One of the things that I dislike about Rhino Mocks is the disconnect between methods that return a value and methods that do not. The first are handled quite naturally using Expect.Call() syntax, but the later have to use the LastCall syntax, which is often a cause of confusion. There is little to be done there, though, that is a (valid) constraint place there by the compiler, can't do much there, right? Jim Bolla had a different idea, and had a great suggestion, so now we can write this: IServer mockServer = mocks.CreateMock<IMock>(); Expect.Call(delegate { mockServer.Start(); }).Throw(new InvalidConigurationException()); // rest of the...

posted @ Wednesday, October 17, 2007 12:01 AM | Feedback (10)

Rhino Mocks: Extending the Mockable

Well, thanks to Ivan Krivyakov, who did most of the work, this is now possible: [Test] public void CanMockAppDomain() { MockRepository mocks = new MockRepository(); AppDomain appDomain = mocks.RemotingMock<AppDomain>(); Expect.Call(appDomain.BaseDirectory).Return("/home/user/ayende"); mocks.ReplayAll(); Assert.AreEqual(appDomain.BaseDirectory, "/home/user/ayende" ); mocks.VerifyAll(); } 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...

posted @ Tuesday, October 16, 2007 10:03 AM | Feedback (5)

From my mail box, Rhino Mocks bugs

I need about 3 hours to sit on those, and I can't seem to find the time. I take comfort that at least they are interesting bugs (my keyword for "I don't have a clue what to do here").

posted @ Monday, August 27, 2007 11:19 PM | Feedback (0)

New Rhino Mocks Logo

Here is a beautiful logo that Romeliz Valenciano has sent in response to my post about advertising Rhino Mocks.   Here it is at 120x90, with the text that I am thinking about: A dynamic mock object framework for the .Net platform. Rhino Mocks eases testing by allowing creation of mock implementations of custom objects and verifying interactions between them.         Update: Updated ad text with Geoff & Sneal suggestions.

posted @ Tuesday, July 31, 2007 4:53 PM | Feedback (16)

Method Equality

The CLR team deserve a truly great appreciation for making generics works at all. When you get down to it, it is amazingly complex. Most of the Rhino Mocks bugs stems from having to work at that level. Here is one example,  comparing method equality. Let us take this simple example: [TestFixture] public class WeirdStuff { public class Test<T> { public void Compare() { Assert.AreEqual(GetType().GetMethod("Compare"), MethodInfo.GetCurrentMethod() ); } } [Test] public void ThisIsWeird() { new Test<int>().Compare(); } } This is one of those things that can really bites you. And it fails only if the type is a generic type, even though the comparison is made of the closed generic version of the type. Finding the root cause was fairly...

posted @ Friday, July 27, 2007 1:01 PM | Feedback (7)

Visual Basic User Group Talks, Next Wendesday

Oh, another thing that is worth mentioning is that I am going to talk about Test Driven Development and Interaction Based Testing at the VB.Net User Group meeting next week (Wendesday, 04 July, 2007). More details can be found here: http://www.renaissance.co.il/ivbug/ The first one is: Getting to know Test Driven Development & Design You have just finished implementing the new WizBang 2.0 feature, and...

posted @ Thursday, June 28, 2007 7:08 PM | Feedback (0)

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 {...

posted @ Saturday, June 23, 2007 6:18 PM | Feedback (10)

Rhino Mocks Events: Twisting the Syntax

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?

posted @ Saturday, June 09, 2007 6:48 AM | Feedback (9)

Rhino Mocks Events: Purity vs. Practicality

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(); ...

posted @ Friday, June 08, 2007 11:13 PM | Feedback (4)

The Auto Mocking Container

Several months ago the guys from Eleutian released the Auto Mocking Container, a combination of Rhino Mocks and Windsor container. I looked at it at the time, and I liked it, but I didn't really get a chance to work with it until recently. You can see how a non trivial controller may look like on the left. It has a fair number of collaborators, for data access, logging, notifications, etc. This approach make building the controller very easy: public void DisplayOrdersForApproval() { if (AuthorizationService.AllowedToApproveOrders() == false) AccessForbidden(); PropertyBag["orders"] = Orders.FindAll( Where.Order.Status == OrderStatus.WaitingForApproval && Where.Order.Department == CurrentUser.Department ); } public void RejectOrder(Order order) { NotificationService.OrderRejected(order); Logger.Info("User {0} had rejected order {1}.", CurrentUser.Name,...

posted @ Friday, June 08, 2007 4:52 PM | Feedback (4)

Using Rhino Mocks from VB.Net

I don't get a lot of chances to work on VB.Net, but when I do, it is almost always because someone has a problem with my code (or their code), and I need to look at it. The problem is that I like the syntax (sort of booish :-) ), but I keep trying to think about it like C#, so I keep getting wierd compiler errors. I am probably the only one who learns the VB syntax from opening reflector and switching to the VB.Net view. Anyway, I was asked how you...

posted @ Wednesday, May 23, 2007 3:58 PM | Feedback (1)

Rhino Mocks stats

Just looked at the download page: First release: 02/07/2005 55 releases so far 26,339 downloads Most popular releases: Rhino Mocks 2.9.6 - probably because it...

posted @ Monday, May 07, 2007 6:34 AM | Feedback (2)

Rhino Mocks 3.1 - Released!

At least this time I managed to last a week. New release with a bunch of new features: Stubs are obvious in, here is my previous post about them and the documentation Added logging support for Rhino Mocks - this means that you can now get clearer information about what is going on, you can configure the logging using: RhinoMocks.Logger = new TextWriterExpectationLogger (Console.Out); ...

posted @ Monday, May 07, 2007 6:18 AM | Feedback (2)

Stubbing Rhino Mocks

Phil Haack just posted some code that made me wince: [Test] public void DemoLegsProperty() { ...

posted @ Saturday, May 05, 2007 12:14 PM | Feedback (5)

Rhino Mocks 3.0.5 Released

New features: A old new syntax that is more explicit about the record replay model, courtesy of James Kovacs: MockRepository mockRepository; ...

posted @ Tuesday, May 01, 2007 12:31 AM | Feedback (2)

How to get attention (and fixes) fast

I just got a bug report for Rhino Mocks from Kevin Miller. Those are not that common, but not very rare. That one came with a test case, which is also fairly common for bug reports (after all, Rhino Mocks is used in TDD scenarios :-) ). I gave it a glance, saw that it had a lot of stuff that I needed to read, and started to put it on my ToDo list. Then I looked at the attached file name. For no particular reason, I have this convention of putting all...

posted @ Tuesday, May 01, 2007 12:21 AM | Feedback (1)

Rhino Mocks 3.0.1: Bug Fixes Release

You can get source and binaries here. This release fixes two issues with the 3.0 release: Trying to mock COM interfaces (specifically, IE interfaces) throws an exception. Trying to pass a Do() delegate for a generic method call where some of the incoming parameters are generic parameters throws an exception.  

posted @ Thursday, April 05, 2007 4:50 AM | Feedback (0)

Guidelines to using Interaction Based Testing

One of the major differences between interaction based and state based testing is the level that you are testing the code. State based testing is testing results of an operation, interaction based testing tests the operation itself. This means that you can get into situations where you are atrophied by the tests. Any change to the code causes a cascading affect on all the tests. Here are some guidelines that should help in this regard. They all boil down to "A Test Should Check Only One Thing". This means that we need a distinction...

posted @ Thursday, April 05, 2007 4:40 AM | Feedback (3)

Tomorrow on Dot Net Rocks: Oren Eini On nHibernate and RhinoMocks!

Be sure to listen, it was a very interesting discussion.

posted @ Wednesday, March 28, 2007 10:53 PM | Feedback (0)

Rhino Mocks 3.0 Released!

I gave it a few weeks outside, and quite a few people downloaded and tried it, so I am feeling good about it. I had a surprised that kept me from release the 3.0 for a while, but I'll talk about it later. The binaries and code are in their usual place, here. BREAKING CHANGES: Moved all the constraints to Rhino.Mocks.Constraints namespace. This was done to avoid conflicts with NUnit and...

posted @ Wednesday, March 28, 2007 12:39 AM | Feedback (8)

Rhino Mocks - Conditional Expectations

Here is an interesting usage of Rhino Mocks: mockAuthenticationSvc = Mocks.CreateMock<IAuthenticationService>(); Expect.Call(mockAuthenticationSvc.IsValidLogin("test", "test"))     .Return(true).Repeat.Any(); ...

posted @ Thursday, March 15, 2007 6:15 PM | Feedback (2)

Murphy's Revenge

I was just preparing a big surprise to celebrate the release of Rhino Mocks 3.0 (expected very soon), when I run into a critical bug in the handling of non generic types inheriting from generic types, basically:public interface IUserRepository : IRepository<User, string> {}  The above can't be mocked. And nothing caught it until I was doing some "let us show the new stuff" preparations. As an aside, 85% of the bugs in Rhino Mocks at the moment can be traced directly to generics support. (10% are related to custom attributes support and another 5% is new features that aren't playing...

posted @ Thursday, March 15, 2007 2:42 AM | Feedback (0)

Wackiest Mocking Strategy?

I am starting to see a lot more refernces to Rhino Mocks in blogs and articles, which is really great. What is interesting is that I get to see a lot of mocking related code (either on the Rhino Mocks list or directly). People are doing some crazy stuff with Rhino Mocks, things I never imagined that they would do. What is the strangest thing that you ever used a mock object for? For myself, I used it to implement an in memory database based on expectations matching the...

posted @ Wednesday, March 14, 2007 1:31 AM | Feedback (6)

Rhino Mocks: Examples from the real world

From the WatiN mailing list, using Rhino Mocks to verify that exceptions originating from IE won't fail the test: [Test] public void ExceptionsInDialogHandlersShouldBeLoggedAndNeglected() ...

posted @ Friday, March 09, 2007 4:07 PM | Feedback (0)

Rhino Mocks 3.0 Beta 4

Well, a bit late, there is a new beta out. Don't bother to looks for beta 3, it doesn't exists, turned out that I named the beta 2 "beta 3", so I skipped a number. Changes: Regression with closed generic types inheriting from open generic types that contains generic properties of the generic type, if the property is overriden Fixed a problem with the new semantics of CallOriginalMethod ...

posted @ Tuesday, March 06, 2007 6:21 AM | Feedback (2)

Rhino Mocks 3.0: Beta 2 Released

Took a bit longer than I anticipated, since people found some really hard bugs with regards to the generics support. I now know a lot more than I ever wanted to about generics, and I considered myself an expert before-hand. Anyway, the new bits have: Improved support for wacky generics scenarios. Thanks to James and Thierry. Better support for types having non inheritable attributes that...

posted @ Sunday, February 25, 2007 7:34 AM | Feedback (11)

Generics Challange: Solved

Take a look here to see what it takes to solve my previous challange. It was extremely hard to get it to work in all scenarios, and I am pretty sure that there are additional edge cases that I have not thought of, but for now, all the tests are green. I also have a 100% repreducable (on several machines) VS crashing bug, which is about the fifth that I know of. I actually started to put MsgBox.Show() in the code, and had a serious JavaScript deja-vu as a result...

posted @ Sunday, February 25, 2007 1:21 AM | Feedback (2)

Mocking Injection

The guys from Eleutian had done it again, with a post that explains how you can use Windor and Rhino Mocks in order to make it easy to create the tests. Jacob is raising some concerns about this approach:Speed/peformance? Does making the container such an integral part of the test fixtures hurt performance? Setup has to be longer when we're creating the container the way we are. Does this matter? Only as long as the time saved when writing tests is larger than the time it takes to run them, which I'm sure is...

posted @ Friday, February 23, 2007 9:55 AM | Feedback (0)

Rhino Mocks 3.0 Beta Released!

Took a while, and a lot of effort, but it is here. Thanks to Hammett who did all the hard work making Dyanmic Proxy 2. New stuff: Generic Methods (at last!) Support arrays of value types as out parameters Support non-CLS Compliant value types such as UInt64 ...

posted @ Saturday, February 17, 2007 4:07 PM | Feedback (7)

Rhino Mocks Coverage

Right now I got 99.5%+, which should be enough (this means that I got three lines that aren't covered by tests, and I think that this is acceptible. Next in line is to update the documentation and push the build out. As it looks now, there will not be a 1.1 release this time. If it is a major obstacle for you, please let me know.

posted @ Saturday, February 17, 2007 2:20 AM | Feedback (0)

Rhino Mocks 3.0 Beta: Almost Ready

I just got a bing sound from the computer, telling me that an important message has arrived: ------ Test started: Assembly: Rhino.Mocks.Tests.dll ------ 486 passed, 0 failed, 0 skipped, took 6.56 seconds. Yup, that is correct. All, but all, of Rhino Mocks tests are currently passing. What is so suprising about Rhino Mocks passing all its tests? The surprising part is that now...

posted @ Friday, February 16, 2007 6:22 PM | Feedback (6)

Big Surge in the Rhino Mocks Mailing list

For some reason, unknown to me, the Rhino Mocks mailing list started to get a lot more traffic recently, after being silent for quite a while...

posted @ Thursday, February 15, 2007 8:18 AM | Feedback (2)

Rhino Tools Worth $1,000,000 ?!

I registered Rhino Tools with Ohloh (which, in Hebrew, means "On no!"), you can find the project site here. Ohloh is a project assesment site, you point it at a repository, and it does its thinks and push a nice graph in the end. Appernatly, it would take 18 years and nearly million dollars to create Rhino Tools. I'm also very surprised by the amount of code that it found, 75 thousands lines of code? I told it to estimate Castle, I wonder what it would...

posted @ Tuesday, October 17, 2006 9:03 PM | Feedback (0)

Rhino Mocks 2.9.2 Released

This is a maintaince release, which fixes an issue with mocking a type whose method comes from several assemblies (inheriting a type from another assembly, that is) where some of those methods are internals, and InternalsVisibleTo is only applied to one of those assemblies. Fairly specific bug, I would say :-) Anyway, source and binaries are here  

posted @ Monday, October 16, 2006 10:56 PM | Feedback (0)

The New Repository: Rhino Tools

Following the advice from the comments, I have managed to consolidate my various OSS SVN repositories into a single one, hosted at source forge. I was quite suprised that it was so much, to tell you the truth. The repository URL is: https://svn.sourceforge.net/svnroot/rhino-tools/trunk/ To checkout, execute:svn co https://svn.sourceforge.net/svnroot/rhino-tools/trunk/ rhino-tools There is no password necceary for reads. I'll be update the various links on the site to point to the correct location soon.

posted @ Saturday, October 14, 2006 6:03 PM | Feedback (1)

Rhino Mocks 2.9.1

I am happy to accounce Rhino Mocks 2.9.1, which came after quite a dry spell... The changes are: Added Message() to Method Options, allowing more structured way to add intent to expectations described in more details here. Added operator && and || overloading to constraints Added Is.Matching<T>(Predicate<T> pred) constraint ...

posted @ Monday, September 11, 2006 3:44 AM | Feedback (1)

Clarifying interaction based testing

One of the big advantages to state based testing is the clearer error messages, like this:Assert.AreEqual(5, collection.Count, "Expected to have 5 broken rules as a result of XYZ"); Using interaction based testing, you usually can specify much less information: validationResult.AddBrokenRule(null); LastCall.IgnoreArguements().Repeat.Times(5); Is this a setup code? Is this the expected result of the test? Who knows? Certianly not me in tree weeks (or months) times, when this test is broken and I need to figure out why....

posted @ Wednesday, August 30, 2006 1:19 PM | Feedback (8)

Rhino Mocks 2.9

Just to make it clear, this version does not make use of the new Rhino Proxy. This is a bug fix release, to fix an issue with two recorders inside the root recorder and an unexpected methr call, they would then each forwarded the replay request to the root, which would then begin from scratch, etc. Anyway, the details are probably boring, but the result will bring some relief to at least one user. Happy mocking, The source and binaries are in the usual place

posted @ Sunday, August 20, 2006 12:42 AM | Feedback (0)

Spiking Rhino Proxy - Dynamic Proxy on CodeDOM

What is Rhino Proxy? Rhino Proxy is a little spike of mine, duplicating the work that has gone into Dynamic Proxy, but using CodeDOM, instead of Reflection.Emit. The good news is that it took me about 3 days to duplicate nearly all the the functionality in Dynamic Proxy (I didn't do events, but it should be easy enough to do). The really good news are that I managed to support generics methods interceptions, so interfaces like this are now valid: ...

posted @ Saturday, August 19, 2006 8:33 PM | Feedback (0)

Thinking about Rhino Mocks 3.0

I am thinking about the Rhino Mocks 3.0 release, and I wondered what features  or bug fixes you think would be good for it. Rhino Mocks has a vastly under utilized bug tracking here, so feel free to use it. One thing that is definately going to be is a Wiki so users can add their own content to the documentation. I just can't keep the docs updated anymore.

posted @ Sunday, August 13, 2006 7:05 AM | Feedback (2)

Rhino Mocks Limitations

I'm getting a lot of questions recently about Rhino Mocks, and I wanted to address the common one here. Rhino Mocks at the moment has two major limitations: It cannot mock interfaces or classes with generic methods, like this one: public interface IFoo ...

posted @ Wednesday, July 19, 2006 9:18 PM | Feedback (3)

Rhino Mocks And Interfaces With Generics Methods

I the last week I was asked multiply times about using Rhino Mocks to mock interfaces with generic methods. At the moment, this is not working, the code needed to generate generic methods on runtime is not trivial, and I tried fixing it several times, without success. Currently, Dynamic Proxy 2 is being worked on, which will have support for generic methods, so I expect to have this feature soon. The following hack will get you by for now, it is not ideal, but it is what I have at the...

posted @ Wednesday, June 28, 2006 7:42 AM | Feedback (0)

This Is Not Only One Of The Nicest Logos That I

This is not only one of the nicest logos that I have seen, it is also the logo of Rhino Mocks Boo Macros, which is a language extension for Boo that integrate Rhino Mocks directly into the language.   Andrew Davey released it today, and it completely blew me away. I did some Boo hacking, and I have a fully appreciation of the scale of the task that Andrew had.   Check out how simple it looks:   [Test] def Example():     record mocks:         foo as IFoo = mocks.CreateMock(IFoo)         expect foo.Dog(int, x as string, y as int):             x...

posted @ Wednesday, June 28, 2006 12:33 AM | Feedback (1)

Using Rhino Mocks To Unit Test Events on Interfaces

Phil Haack has posted a really nice post about using Events with Rhino Mocks. On other news, I saw today a Rhino Mocks question in a general .Net forum. Bliss :-D

posted @ Friday, June 23, 2006 10:12 PM | Feedback (0)

Rhino Mocks 2.8.8 - Finalizer, Orderring and more

Okay, I manage to hold out for over a week without releasing it, but the code started snarling at me when I worked with it, so I suppose I have better let it free. This release contains multiply fixes for orderring, including some really bizzare edge cases. In addition to that, Eric Nicholson was kind enough to send a patch that fixes an issue with mocking classes that has finalizers. Just to make things interesting, you can find only the binaries here. I decide to keep the source for myself...

posted @ Friday, June 23, 2006 2:22 PM | Feedback (1)

Rhino Mocks 2.8.7

Yesterday I applied the fix to Ordered orderring only, but not to unordered orderring. This release fixes it. Code and binaries are here. The regular rambling will be resumed shortly.

posted @ Wednesday, June 14, 2006 5:14 AM | Feedback (4)

Rhino Mocks 2.8.6 - Bug Fix Release

Well, this time it was an interesting release. Well, interesting to me at least :-) The issue was nested orderring and expectations that can be called over a range of values (in this case AtLeastOnce() ). Rhino Mocks didn't handle this case correctly, and this require some minor changes to the way calls are routed internally. The interesting part was that solving this edge case opened up another, unexpected method call on orderring boundary, which was a bit harder to solve. Anyway, it is fixed, and you can check the...

posted @ Tuesday, June 13, 2006 10:31 PM | Feedback (0)

Rhino Mocks Experimental Feature - With.Mocks

I'm going to stray from my usual quick release cycle for Rhino Mocks for this feature. The idea is to take this idea and apply it to Rhino Mocks. Here is the result that I have at the moment: [Test] public void UsingTheWithMocksConstruct() ...

posted @ Thursday, June 08, 2006 9:59 PM | Feedback (7)

Rhino Mocks 2.8 Released – Multi Mocks

I said it before, but I just have to say it again. It is a big mistake to release software. Any time that I do it, I need to make a new release soon after. (And no, not a bug fix release {usually} ). Yet I did make the mistake of releasing the most dangerous software of them all, Rhino Mocks. The moment I do something to this beast, a new feature request come up. The problem is that I’m a sucker for frequent releases, I just can’t help implement features and ship them. This release brings one major feature to...

posted @ Tuesday, May 30, 2006 7:32 PM | Feedback (0)

Rhino Mocks Mailing List on the site

I just found out that my Rhino Mocks Mailing List (I use google for it) has an RSS feed. It was a matter of a couple of moment to add the RSS to the site, since Cuyahoga has a Remote Content module. This way you can see the last few messages when you are on the page.

posted @ Wednesday, April 19, 2006 10:05 PM | Feedback (0)

On Comments, Yet Again

After making such a point about commenting being mostly noise, and that code should be able to stand on its own, I found myself adding the following comment (related to this issue) to Rhino Mocks. //This can happen only if a vritual method call originated from  //the constructor, before Rhino Mocks knows about the existance  //of this proxy. Those type of calls will be ignored and not count //as expectations, since there is not way to relate them to the ...

posted @ Monday, April 17, 2006 10:20 PM | Feedback (0)

Rhino Mocks 2.7.1: Virtual Calls From Constructors

In many ways, I feel that I'm still a C/C++ programmer, despite 5 or so years of almost exclusive .Net work. I found myself playing with the scope of the variables inside a method, trying to make sure that they would only be allocated once. It's only after I did it that I realized that it just doesn't matter for the CLR, since local variables has the same lifetime as their method and are only allocated once. Today I had a bug that came from the same C++ thinking, I didn't consider what...

posted @ Monday, April 17, 2006 10:02 PM | Feedback (2)

Advnace Mocking Scenarios With Active Record (using Rhino Mocks)

My recent post sparked some discussion in the Castle Mailing List, with some question of how to handle more complex scenarios. I managed to code those without much problem, as you can see below, but a few words first. This method essentially mocks NHibernate for Active Record. This means that you have to understand what is happening (which is not a bad idea). I'm intimately familiar with both Active Record and NHibernate, and I had to look at the source to see what was happening.  If you intend to use this method, I highly...

posted @ Friday, April 14, 2006 7:45 PM | Feedback (2)

Rhino Mocks in the User Groups

It looks like there was a User Group presentation in Dayton about Test Driven Design that also included Rhino Mocks. You can get the presentation and the code samples here. Very cool.

posted @ Saturday, March 25, 2006 9:05 PM | Feedback (0)

get-state "Open Source Projects"

Scott Hanselman posted about open source projects. He poses the question: "If you work on a Open Source Project, why do you do it? When will you stop?" I literally has to stop and think about the number of open source projects I'm involved with. Right now it is: Rhino Mocks - Under active development with a community that send patches when they run into problems. Really cool project. Started because I had too many problems with NMock and refactoring. ...

posted @ Friday, March 24, 2006 7:28 PM | Feedback (0)

Code I'm Proud Of

The recent work I did with graphs reminded me the time I wrote the orderring functionality in Rhino Mocks. (I asked my warders about it, and they still rib me about order in inorder recursively). It was one of the trickest parts in Rhino Mocks, to find an interface that will allow nested orderring behaviors that will be invisible for the users. In the end, I went with a variant of both chain of responsibility and composite. I worked very hard (and had a lot of tests) for this part of Rhino Mocks,...

posted @ Friday, March 24, 2006 9:32 AM | Feedback (0)

Rhino Mocks 2.7: Events

I finally got rid of the coding block, and I think I compensated by a large degree. Rhino Mocks has a new and improve version, including: Support for raising events Improved support for remoting mocks Fixed a bug with regard to interfaces with the same name on different namespaces. Check out the events: ...

posted @ Sunday, March 19, 2006 9:46 PM | Feedback (0)

Matt on Rhino Mocks

I just read this post from Matt about Rhino Mocks and events. I recall seeing something very similar to that in the Rhino Mocks mailing list, but it never made it to the code base. Reading the post, the capabilities are awesome. I'll need to take a much closer look at this, and see if I can make it work on 1.1 as well, but this is defiantly going into the next release.

posted @ Saturday, March 11, 2006 11:43 AM | Feedback (0)

Good News On Rhino Mocks

I just got an email in the Rhino Mocks Mailing List, talking about 25% performance improvement in using 2.6.6 over 2.6 ! Those are the news I like to hear!

posted @ Wednesday, March 08, 2006 6:42 PM | Feedback (0)

Documentation Update

I updated my Projects page with some annoucements, and when I wrote the Rhino Mocks updates I noticed just how many changes I made to it. It's both cool and scary. The nice thing about it is that I don't have a lot of documentation to write, since I didn't change much outfacing functionality. I already updated the documentation for NHibernate Generics, so that is done. The documentation on this site for Brail is deprecated! You should use the Castle website documentation. I'm going to update this one as soon as I can find the time to do so. This is the one project where...

posted @ Tuesday, March 07, 2006 2:29 PM | Feedback (0)

Documentation & Open Source

One of the worst thing about doing open source software is maintaining the documentation. I recently had changed Rhino Mocks, NHibernate Generics and Brail. This mean that I have to update the documentation of all three of them, and I'm less than excited about doing that :-(

posted @ Monday, March 06, 2006 10:37 PM | Feedback (3)

Rhino Mocks 2.6.6: Bug Fix Relase - StackOverFlow when overriding Equals

Okay, I got a bug report today about something I knew I fixed. A StackOverFlow exception when overriding Equals(). Looking at the code, I did fix it, for 1.1 (this is one of the few places where there is a difference between the versions, unfortantely). More unfortantely, I didn't have a test for this, and I'm not sure why. IIRC, I got those exceptions by the dozens when I got this error, so I never bothered to write a spesific test for it. In hindsight, those exceptions where for Object.Equals(), which is not...

posted @ Monday, March 06, 2006 10:33 PM | Feedback (0)

Rhino Mocks 2.6.5: CLS Complaint

It's starting to feel like an hourly thing, I must say. There is a new version of Rhino Mocks out, the only change is that I made this version CLS Complaint, so it should give you a warm fuzzy feeling in your heart when you use it. :-) Do I really need to give the URL again? Okay, get the sources and binaries from this page.

posted @ Saturday, March 04, 2006 8:31 PM | Feedback (0)

Rhino Mocks 2.6.4: Bug Fix Release

I think that I should drop a note about all the three recent releases. In version 2.6.2 I changed the way Rhino Mocks handles dynamic code generation to make sure that Rhino Mocks would only generate the a type for a mock type once. Before, it would generate the mock type for each MockRepository. The meaning of this change is huge memory optimization, and a significant performance increase. The downside is that bugs that weren't noticable when the types were geberated to different assemblies now surface. The main issue were generics, where the...

posted @ Saturday, March 04, 2006 12:21 PM | Feedback (0)

Rhino Mocks 2.6.3: Bug Fix for regression with generic types.

Okay, now you know why I try to avoid releases of Rhino Mocks, every time I make a release, I usually have a week of sudden activity, with new features / fixes coming in. This time it's a regression that happened with regard to generic types. The issue is that you can't mock any generic type more than once. I had tests for mocking generic types, but I didn't have any tests for trying the same type multiply times. Well, now I do, and it's fixed. So you can go...

posted @ Tuesday, February 28, 2006 10:57 PM | Feedback (1)

Rhino Mocks 2.6.2: Memory Requirements Improvements

Okay, this release should be a major improvement memory wise, I changed the implementation so instead of generating dynamic assemblies per MockRepository, all the Mock Repositories will generate to the same assembly. This should prove to be a dramatic reduction in the amount of space that Rhino Mocks consumes.  Sources and binaries are avialable here.

posted @ Monday, February 27, 2006 8:50 PM | Feedback (0)

Rhino Mocks 2.6.1: BackToRecord Updates

There was a bug in the BackToRecord() method when using Dynamic or Partial mocks. This update fixes this issue. Sources and binaries are avialable here.

posted @ Saturday, February 25, 2006 9:23 PM | Feedback (1)

Rhino Mocks 2.6

Okay, there is a new version on the site, with a couple of bug fixes: Support for methods that start with get_ & set_ that are not properties. Fixed BackToRecord() not cleaning up repeatable expectation (read: SetupResult). Added Is.TypeOf<int>() to save some typing. This was suppose to be the version that would bring the ability to mock generic methods like...

posted @ Friday, February 10, 2006 10:24 PM | Feedback (1)

Rhino Mocks 2.5.9

My name is Ayende Rahien, I'm a software developer, it has been five days since I last release a version, but I can't hold myself anymore. Yes! A new release for Rhino Mocks, with better support for method with array of value type arguments. I would like to thank to J.H.L. van de Pol for sending the patches and for converting to Rhino Mocks. You can get the new bits and the source here. Now I need a new feature for Rhino Mocks so I can...

posted @ Monday, January 09, 2006 9:01 PM | Feedback (3)

Update to Rhino Mocks 2.5.6

Not a new release, but a very nice productivity enhacer. Instead of using the huge string that I showed in the previous post, just use this declaration:[assembly: InternalsVisibleTo(RhinoMocks.StrongName)]

posted @ Wednesday, December 21, 2005 10:07 PM | Feedback (0)

Rhino Mocks 2.5.6: A Tiny Bug Release

This is a release for a very specific case, you want to mock an internal class from a strongly signed assembly. Now all you need is to add this declaration to you assembly and you're set: [assembly: InternalsVisibleTo("DynamicAssemblyProxyGen, PublicKey=002400000480000094000000060200000024000052534131 0004000001000100fb4ff5a7c8bba6feb6a6b75b260cd57c1b8b85b63a45dedcb7081331740c870852af30abd2a74700cce1d7a01ae ed019339db202e010ac808396b2922362877c6afc8993281092434a223b9920cac8ba409d138a97b73cd1baad813af450b886e3d7f 5a09ee450d415145eb0524778a6bd1ae733fd2b6ceebfd151620534bcb7")] The...

posted @ Wednesday, December 21, 2005 8:58 PM | Feedback (0)

Rhino Mocks 2.5.5: Mocking Delegates

A brand new release of Rhino Mocks, with a twist. Jeff emailed me a patch yesterday, that enabled the mocking of delegates. This is not something that I would've ever considered, to tell you the truth, but the idea (and the code) were sound, and I can certainly see uses for this. Consider all the possibilities for near-functional programming that .Net 2.0 opens for us, and you'll see what I'm excited about. Here is an example of using this new functionality:[Test] public void GenericDelegate() { ...

posted @ Saturday, December 17, 2005 10:38 AM | Feedback (2)

Rhino Mocks 2.5.4

Yes, I know that I said that I'm not going to post today. But Jeff fixed a problem with Partial Mocks (couldn't call a method that had parameters). It's 0:45AM, and I'm releasing software... I think that I could be arrested for this. :-) As usual,  you can download it, or access the source directly. Thanks Jeff, and it really is turning into a daily build project :-D

posted @ Tuesday, November 29, 2005 10:53 PM | Feedback (0)

Rhino Mocks 2.5.3: Out & Ref

This time I actually did nothing for this release. Jeff Brown added support for Out & Ref parameters for Dynamic Proxy, and all I had left to do is hit the build button a couple of times and upload the stuff to the server. This closes the next to last big problem with Rhino Mocks. The very last one has to do with generic methods, which I hope to be able to fix this week.  You know the drill, you can download it, or access the source directly.

posted @ Tuesday, November 29, 2005 6:23 AM | Feedback (0)

Class Diagram for Rhino Mocks

I created an annonated class diagram for Rhino Mocks. It's quite big, but here is the small version: I created this using Visual Studio 2005. Click on the image to see the large version. The diagram describe Rhino Mocks 2.5.2, released yesterday.

posted @ Tuesday, November 22, 2005 11:29 PM | Feedback (1)

Rhino Mocks statistics

Here are a couple of interesting statistics about Rhino Mocks that I pulled from Cuyahoga. For this table, I merged the results of Rhino Mocks for .Net 2.0 and for .Net 1.1. You can see that the distribution of releases is pretty standard, a flurry of releases, pause, a flurry of release, etc. Rhino Mocks 2.4 is the most popular download, it was the version that added .Net 2.0 features. Rhino Mocks 1.0 was based on EasyMock.Net, I abandoned the code base after it proved to be too hard to maintain and since...

posted @ Monday, November 21, 2005 11:47 PM | Feedback (0)

Rhino Mocks 2.5.2

Okay, this time it is a bona fide bug, a good one. Rhino Mocks didn’t respect ordering if you were using dynamic mocks. You know the drill, you can download it, or access the source directly. It has been two days since the last release, and here I thought that I'm not practicing daily builds.

posted @ Monday, November 21, 2005 10:50 PM | Feedback (0)

Rhino Mocks 2.5.1: Partial Mocks

Can someone please tell me why I almost always make Rhino Releases in bunches? The second I make a release, another thing pop up and I have to make another one. Rhino Mocks 2.5 is barely out the door, and here I've another great feature. Partial Mocks: Partial mock is a mock object whose default action is to call the original method. Why is this useful? It's useful because you may want to test an abstract method, and you don't want to write a...

posted @ Saturday, November 19, 2005 11:12 PM | Feedback (0)

Rhino Mocks 2.5: Weekend of Code

I'm not really sure why, but of late, there has been a lot of traffic in the Rhino Mocks mailing list. Most of it about new features that people requested, and including some really good patches (thanks to Brian and Geert). Here is a list of the new features: You can now move a mock object back to record mode, this allows you to specify the interactions between the object in small steps every time. ...

posted @ Saturday, November 19, 2005 2:31 PM | Feedback (1)

Rhino Mocks 2.4.2: The Unmocker

Okay, so I've a new release out (any time I push out a release, I just know that I'll have to have a new one ready in a short time). So, what is the story here? Some time ago I added the ability to easily create stub objects and dynamic mocks. So you could do something like this: IList list = mocks.DynamicMock<IList>(); SetupResult.For(list.Count).Return(5); mocks.ReplayAll(); ...

posted @ Friday, October 21, 2005 11:38 PM | Feedback (0)

Rhino Mocks 2.4.1 Broken

I would like to apologize for anyone who downloaded build 2.4.1, it was broken, the dynamic proxy wasn’t merged properly. I would also like to thank David for reporting the problem. I was offline for the last three days, so I wasn’t aware of it. It’s fixed now both in the repository and in the site, just re-grab 2.4.1 and it will be fine. 

posted @ Friday, October 14, 2005 3:00 PM | Feedback (0)

New Rhino Mocks release

Well, it's been a while since the daily release cycles, but I've another release out, 2.4.1 This one adds the ability to mock abstract classes. It's strange, but until today I recieved no requests about it. This release also comes with a custom version of Dynamic Proxy. Usually you won't have to worry about that, unless you intend to hack Rhino Mocks, and so far it doesn't seems like it would be neccecary. Oh, the download is in the usual place.

posted @ Wednesday, October 12, 2005 12:16 AM | Feedback (2)

Rhino Mocks 2.4 Documentation Update

I've updated the documentation to include the latest changes. It's available here.

posted @ Friday, August 26, 2005 3:43 AM | Feedback (0)

Rhino Mocks 2.4 - More on DRY

As I said, I update the minor version number every time I add a big feature, this time it's all about DRY and .Net 2.0. From the start Rhino Mocks was capable of being used on the 2.0 framework, but its home was the 1.1. That caused some pain to me every single time that I had to write something like: IDemo demo = (IDemo) mocks.CreateMock(typeof(IDemo)); Just count the number of times that I repeat the type of the mock object here, three times! This is stupid and it violate the DRY principal in a fairly...

posted @ Thursday, August 25, 2005 11:45 PM | Feedback (0)

Partial classes question

Given this class declaration: File1: public partial class MocksRepository : IDisposable {    //implement disposable }  File2:public partial class MocksRepository : IDisposable { } Why do I get an error saying: Error 1 'Rhino.Mocks.MocksRepository' does not implement interface member 'System.IDisposable.Dispose()' D:\Code\rhino-mocks\src\Rhino.Mocks\MocksRepositoryGenerics.cs 12 26 Rhino.Mocks 2.0

posted @ Thursday, August 25, 2005 1:57 PM | Feedback (0)

Rhino Mocks 2.3.5 and events

The release is available here. Another bug fix release, this time allowing to mock interfaces that inherits from IClonaeble. But this isn't the reason for the post, I wanted to talk about using events in a mocking framework. As events are such an important part of the .Net framework, I decided (encouraged by a user question) to check to see how it works. I wasn't surpirsed (DynamicProxy is cool) to see it was already inside and very easy to do. Here is how you check that the object under test...

posted @ Thursday, August 25, 2005 12:44 PM | Feedback (0)

Anouncing: Rhino Mocks magazine

As the Rhino Mocks Mailing List reached the respectful number of 12 (one of which is me :-), I decided that this is truly the time to expand a bit and start my own magazine which will deal with all those issues that developers have to face when creating test and mock objects. Here is the first edition of Rhino Mocks Magazine:  Created by the amazing Flickr Magazine Cover

posted @ Wednesday, August 24, 2005 2:31 PM | Feedback (0)

Rhino Mocks reach 100% testability

I took a bit of time to work on Rhino Mocks today, mainly cleaning up some stuff and rearranging things. It occur to me that after getting so excited about Rhino's tests earlier today, I might check the code coverage reports*. The first report that I got was quite disappointing, I had only 57% coverage. I had such high hope and they were thoroughfully dahsed. Then I remembered that I used CodeSmith to generate custom collections for Rhino. NCover doesn't allow you to exclude namespaces, which made it impossible to see the code coverage excluding this annoying code generated files. I wrote quick & dirty script in Boo that...

posted @ Thursday, August 18, 2005 10:10 PM | Feedback (1)

Rhino Mocks 2.3.3

I just realized that I spent about as much time writing the previous post as I did fixing the bug :-) If you don't feel like reading reams of text, there was a bug in Rhino Mocks regarding the handling of classes which override GetHashCode() and/or Equals(). The bug is fixed (and I was very excited about it, apperantly). The new version can be found here and the source is in the repository.

posted @ Thursday, August 18, 2005 8:23 AM | Feedback (0)

Release Story: Rhino Mocks 2.3.3

So I'm sitting by the computer reading something and suddenly the new email sound startles and the Bugs folder in Outlook light up. This usually don't happen unless I enter a bug into my bug tracking system, so naturally I was curious about the nature of the bug and the person who entered it. I still don't know who entered the bug (a very annoying problem in Flyspary, you seem to have to register to enter bug non anonymously) but the bug was a masterpiece. It had a clear explanation of the problem as...

posted @ Thursday, August 18, 2005 8:18 AM | Feedback (0)

Rhino Mocks API

I’ve used Natural Docs to generate some initial documentation for Rhino Mocks’ API, which is available at: Rhino Mocks API   There is one nasty bug that I found by reading the code, which is that Rhino Mocks doesn’t verify the expectations if you’ve set a method to throw an exception. ...

posted @ Wednesday, August 17, 2005 9:43 AM | Feedback (0)

Updated Rhino Mocks Documentation

The documentation has been updated to version 2.3 (and made it xhtml compliant, on the way). If you've any comments about that, I would love to hear them.

posted @ Tuesday, August 16, 2005 6:34 AM | Feedback (0)

Rhino Mocks 2.3

If there is such a thing as resting your mind while working, it's what I have when I'm working on Rhino Mocks. I've just finished implementing things I talked about here, it was no small thing to do, as it changes some fundamental assumptions about way Rhino Mocks works. Nevertheless, the actual coding was a breeze. I simply added several overloads, wrote some tests to verify that it worked and it worked. Then I wrote some edge cases tests and fixed the problems. I'd to move some basic functionality from one spot to...

posted @ Monday, August 15, 2005 11:48 PM | Feedback (2)

Rhino Mocks Mailing List

I started this list because I started to get feeedback and questions about Rhino Mocks and I would like to have the answered somewhere outside of my pst file and accessible to the wide world. ...

posted @ Monday, August 15, 2005 8:36 PM | Feedback (0)

Planning the next version of Rhino Mocks

I've been thinking about what needs to be add to Rhino Mocks feature-wise. I spoke with several developers who are using it and I think that I need to add the following: Relaxed mocks - a mock object that allows to set expectations on it, but doesn't care about unexpected calls. This mean that any unexpected call (in the replay state) would be ignored (but you could setup actions for it. throwing or returning a value). Any calls that you does setup expectation for will be verified. So you can say: "Create a mock...

posted @ Monday, August 15, 2005 10:58 AM | Feedback (1)

Rhino Mocks 2.2

Okay, after some more talks with Geert, I made some additional changes to Rhino Mocks' syntax. First things first, no code using Rhino Mocks will break as a result of the changes. But new code should be easier to write & read because of those changes. The idea is simply to make it easier to write expectations, so without further ado, here is the new syntax: IProjectView projectView = (IProjectView)mocks.CreateMock(typeof(IProjectView)); SetupResult.For(projectView.Title).Return("Test Project");//New in Rhino Mocks 2.2...

posted @ Friday, August 12, 2005 10:06 PM | Feedback (0)

Rhino Mocks 2.1

I've updated Rhino Mocks, this time it's a feature adding release rather than a bug fix release. The issue is very simple, previously, when you wanted to set an expectaion on a method with a return value you needed to to this: Expect.On(projectView).Call(projectView.Title).Return("ayende"); This is very nice way to do things, but it is does violate the DRY prinicpal. In this case, there are some valid reasons for this syntax. Considerring that Expect is a static class, I don't have any context to rely on here. I needed...

posted @ Thursday, August 11, 2005 4:43 PM | Feedback (0)

Rhino Mocks goes to China

Rhino Mocks is now international :-) Idior has posted an article [in chinese] about Rhino Mocks. Here is the [google translated] english version.

posted @ Sunday, August 07, 2005 3:47 PM | Feedback (0)

Rhino Mocks 2.0.7

Rhino Mocks 2.0.7 is mainly a bug fix for method orderring bug, but it also present a better package in that that you no longer has to have Castle.DynamicProxy.dll with the Rhino.Mocks.dll No, I didn't implemented my own IL generator, I simply used ILMerge and the results are very satisfying. I'm thinking about doing the same for Brail (which comes with several dlls) but this cause tests to fail, and I didn't have the time to find out what the problem was.

posted @ Sunday, July 31, 2005 7:23 PM | Feedback (0)

Rhino Mocks 2.0.6

Okay, this release is actually an interesting one. The problem it solves is running Rhino Mocks on the .Net 2.0 Framework. Somewhere deep in the bowels of Rhino Mocks, there is a method that return a default value for method that are called during the recording phase, it looks like this: public static object DefaultValue(Type type) {   if (type.IsValueType == false)     return null; ...

posted @ Saturday, July 30, 2005 10:14 PM | Feedback (0)

Rhino Mocks 2.0.5

I'm now signing the assemblies, so you could use them in trusted environments. Made some modifications to the build script as well, to add testing to the build process and to sign the assemblies. Get it here: http://www.ayende.com/projects/rhino-mocks/downloads.aspx

posted @ Friday, July 29, 2005 5:47 PM | Feedback (1)

Rhino Mocks 2.0.4: Yet another bug fix release

It starting to look like a daily build log, doesn't it? :-) Anyway, this time the fix is for preserving the exception message that is thrown when a constructor throws. The code is in the repository and the downloads are in the usual place: http://www.ayende.com/projects/rhino-mocks/downloads.aspx

posted @ Tuesday, July 19, 2005 12:36 PM | Feedback (1)

Rhino Mocks 2.0.3 - Bug fix release

Another bug fix release for Rhino Mocks, didn't took into account repositories with no mock objects. It's on the download page now:  http://www.ayende.com/projects/rhino-mocks/downloads.aspx

posted @ Monday, July 18, 2005 6:17 PM | Feedback (0)

Bug tracking for my projects

I've often spoke of how much I want an easy-to-use bug tracking software, but I never did much about it since no free package was able to satisfy everything that I needed. Specifically, free, open source and working with MySQL. A big plus would've been if it would've been written in C# or Boo. Now, bug tracking is certainly not a hard problem, is mostly direct work against database, some reports and a lot of thinking about work flow. Beyond that, it's mostly grunt work of adding features that are neccecary, but quite...

posted @ Saturday, July 16, 2005 2:27 AM | Feedback (8)

Rhino Mocks 2.0.2: Another minor release

I just spent an hour tracking a bug in Dynamic Proxy, I solved it and was about to send a patch when I run svn update and got a few conflicts. Imagine my horror to discover that the bug has already been fixed (and in a better way), that will teach me to always update before doing work, I guess. Anyway, there is a new version that fix a problem with overloaded indexers that you can use. Since all I did was merely to update the dynamic proxy dll, I edited the bulid...

posted @ Friday, July 15, 2005 11:21 AM | Feedback (5)

Rhino Mocks 2.0.1 - Minor bug fixes

I updated Rhino Mocks with two minor bug fixes: Now it's possible to mock object.ToString() when mocking a class instance. It's not possible to mock ToString() when mocking an interface. It's not possible to mock GetType(), GetHashCode() & Equals() at all. ...

posted @ Tuesday, July 12, 2005 11:20 PM | Feedback (1)

Rhino Mocks on SharpToolbox.com

Rhino Mocks is now on Sharp Toolbox, hopefully this will get some people to start using it (only 42 downloads so far)

posted @ Thursday, July 07, 2005 2:30 AM | Feedback (0)

Don't expect to hear much of me in the next few days

The full bunch of Mercedes Lackey books just arrived, and I'm holding myself by the teeth to not start a reading frenzy that will send the SWAT in. On other news, I found some bugs in Rhino Mocks (edge cases, mostly) and added failing test for them, I'll fix them when I finish with Lackey. I also started (finally) to work on NQA's document editing parts. I already has the back end implemented, and I was able to get very fast progress out of it.

posted @ Monday, July 04, 2005 9:42 AM | Feedback (0)

Solved problem of getting virtual method from constructors in DynamicProxy

I encountered a problem in Dynamic Proxy, it threw a null reference exception when I tried to run the following code: proxy = generator.CreateClassProxy(typeof(ArrayList),new StandardInterceptor(), new int[]{1,2,3}); The reason was that ArrayList::ctor(ICollection ) calls a virtual method, and since Dynamic Proxy intercept all dynamic calls, it recieved the call, but before it had time to initialize itself, so it tried to reference a null pointer. I was quite lost as to what to do, this is something that users of Rhino Mocks would likely want to do, and it's a certainly a general...

posted @ Saturday, July 02, 2005 10:37 AM | Feedback (4)

Rhino Mocks 2.0 Released

I've released Rhino Mocks 2.0 to the wild, beware of rapid productivity increases that may result :-) Anyway, it took so long because I wrote detailed documentation for the project. For such a small library, it sure has a lot of way to use it. You can read the documentation here. And download the binaries and code from here. I wrote this version after seeing how cool NMock2 was, to take advantage of many of the ideas there. The resulting product is very good, IMHO :-D Drop me a line if...

posted @ Friday, July 01, 2005 10:05 PM | Feedback (1)

Rhino Mocks Update

Sorry for not releasing it today, but I was veyr busy all day, and didn't had time to do much about the article. I did find a bug in Rhino Mocks, it only affect code that uses nested orderring and SetupResult, but when I fixed it, I realized that this is a good opportunity to fix the whole nested orderring before I ship the second version, and that took quite a bit of time. I had a very interesting technical discussion about the logic of nested orderring with some very non technical people,...

posted @ Wednesday, June 29, 2005 12:51 AM | Feedback (0)

Mock framework comparison

This is just a quicky, doesn't mean much, but allows a look at how each framework's syntax allows to setup a expectation & return value for a method: NMock: IMock mock = new DynamicMock(typeof(IRequest)); IRequest request = (IRequest)mock.MockInstance; mock.ExpectAndReturn("Username","Ayende"); testedObject.HandleRequest(request); mock.Verify(); EasyMock.Net: MockControl control = MockControl.CreateControl(typeof(IRequest)); IRequest request = (IRequest)control.GetMock(); control.ExpectAndReturn(request.Username,"Ayende"); control.Replay(); ...

posted @ Monday, June 27, 2005 11:52 PM | Feedback (2)

When code surprises you in a good way

[Note: This is another post where I just added over several hours as I added the finishing touches for Rhino Mocks.] I found out something nice about Rhino Mocks, it allows you to specify ordered sequences of unordered method calls. Meaning that I can specify that calls A, B & C would occur in any order, and only after those three calls, the calls for D, E & F would occur (in that order, or in any order). I'm not very clear, but I'm working on an article that should explain it all,...

posted @ Monday, June 27, 2005 11:12 PM | Feedback (2)

Setting of the wrong path, on purpose

That is how I built Rhino Mock 2.0. I've a general idea about how I want it to look like, and I knew that I didn't like the current implementation. I wasn't very sure about how to go about implementing this, however. After my experiances with NQA, and after reading Working Effectively With Legacy Code, I knew that Test First is the way to go. So I started writing tests, and writing code to make them pass. The part that I had a problem with was that I wrote code...

posted @ Sunday, June 26, 2005 11:31 AM | Feedback (0)

TDD Goodness

I just had a complete surprise writing a test for Rhino Mocks. I'm doing that completely Test First, and I wrote a test, expecting it to fail. But it passed. Apperantly I'm already covering this case. :-) This is so nice. [Update: (five minutes later) Now it begins to be scary. I just wrote another test, for a part that I knew should be hard to get working. And it passed as well. The code handles it just fine, even though I thought I would need extensive changes to get...

posted @ Saturday, June 25, 2005 4:36 PM | Feedback (0)

Rhino Mocks V2: Some Progress Made

I made quite a progress, mostly thanks to this article. I'm totally and completely blown away by the capabilities of Castle.DynamicProxy, it open up a whole world of facinating possibilities. For instance, I wanted to get rid of this type of code:MockControl mockView = new MockControl.CreateControl(typeof(IView)); IView view = mockView.MockInstance as IView; view.DoSomething(); mockView.ReturnsFor(3, someVal); I wanted to be able to do something much simpler, like this:MockRepository mocks = new MockRepository(); IView view = mocks.CreateMock(typeof(IView)); view.DoSomething(); LastCall.On(view).Returns(someVal).Repeat(3); It doesn't look like a great improvement, doesn't...

posted @ Wednesday, June 22, 2005 7:43 PM | Feedback (0)

Rhino Mock: Thinking about next version...

I finally got the excuse to work on Rhino Mocks again :-) I've a line in one of my presenters that looks like this: IView[] toSave, unsaved = (IView[]) unSavedList.ToArray(typeof (IView)); Unfortantely, when I pass mocked IViews to this method, the following exception is raised: "System.InvalidCastException : At least one element in the source array could not be cast down to the destination array type." The issue seems to be that Rhino Mocks is uing remoting proxies to do...

posted @ Tuesday, June 21, 2005 8:44 PM | Feedback (2)

Rhino Mocks Future

Taking Rhino Mocks to the next level? So I've improved the interface and added constraints and callbacks, this is nice, but I think I can do more. The first issue on the table is ripping some of the innards of the library and replacing them with something saner. I'd to hack quite heavily to get it to the point it's now. Five to six levels of indirections are not fun to go through when you need to understand what is wrong. I also don't agree with some design and implementation decisions that were...

posted @ Sunday, June 19, 2005 1:38 AM | Feedback (2)

CodeProject article

I put an article in CodeProject about Rhino Mocks, I edited the article in Word, and the strange formatting clashed horribly with CodeProject's formatting. Took a long time to fix. Now it's there, I'm working on a PDF format that will include some more infromation, should be out soon. On other news: I really like what NMock2 can do; I'm going to rip the guts of Rhino Mocks anyway, so I'm going to implement that as well. "IBM: It's Been Malfunctioning" -- Tech Support Slogan "To be,...

posted @ Saturday, June 18, 2005 9:04 AM | Feedback (0)

Rhino Mocks & NMocks 2

I just read Roy's message about NMock2. Vaderpi talks about it in more details, it's look very nice. Here is the original NMock test: [Test] public void ComputeTotal() {   // Create the mock object for item1 and have it return a price of 100   DynamicMock item1Mock = new DynamicMock(typeof(Item));   item1Mock.Strict = true;   item1Mock.ExpectAndReturn(\"Price\", 100);   Item item1 = (Item) item1Mock.MockInstance;   // Create the mock object for item2 and have it return a price of 50   DynamicMock item2Mock = new DynamicMock(typeof(Item));   item2Mock.Strict = true;   item2Mock.ExpectAndReturn(\"Price\", 50);   Item item2 = (Item) item2Mock.MockInstance;   // Add the items to the cart   ShoppingCart cart = new ShoppingCart();   cart.Add(item1); ...

posted @ Saturday, June 18, 2005 3:00 AM | Feedback (2)

Warning, Rhino In The Wild

Well, I'm ready to release Rhino.Mocks, I was right to dog-food it before I release it, I added again the ExpectAndReturn & SetupResult methods, since they are just so much more useful and convenient than doing it on your own. To be short, here is the source, and here is the binary. The source rpository is: svn svn://svn.berlios.de/nqa/Tools/Rhino.Mocks/ I also created a toturial for using it, which can be found here. If you find it useful or think of an improvement, please drop...

posted @ Friday, June 17, 2005 3:49 AM | Feedback (0)