Let’s say you’ve got a mock object and you want a method on your mock to do something with a particular method that goes beyond just returning a specified value. What do you do? Why, you use a function of course! When you stub a method call on a mock you simply tell the mock object... Read more
I’ve written in the past on how to do automatic assembly versioning with TFS Team Build 2008 so it’s about time I got around to showing you how to do with with TFS Team Build 2010. By the way, for a great series of blog posts on customising team build with TFS 2010 it’s worth having... Read more
Recursive mocks (or nested mocks as some people call them) are a feature of the mocking frameworks where they will automatically create mock objects for items they should return if you reference a property or method of that object when setting up expectations. The advantages of doing this are that we have less “arrange” code in... Read more
If you connect to a TFS server with a machine that isn’t in the same domain then you will typically see something like this: So you click the Use different credentials button to login and get a dialog that looks the this. But wait! Where’s the “Remember my password” checkbox?! It’s not there! It’s OK, don’t... Read more
One of the great benefits of using mocks in your tests is being able to check how your classes behave when exceptions are thrown. You do test for this sort of thing, right? :-) Let’s say we have a persistence mechanism that talks to SQL. What happens when we get a SQL primary key violation? What... Read more
I have to wonder at times what goes through designer’s heads and wether they use their own products. Have a look at the following keyboard for a HP machine I’ve been given to use when on site. Look at the size of that Shift key on the left there. The thing is about half it’s normal... Read more
Our comparison of Rhino Mocks, Moq and NSubstitute continues with a look at how multiple calls to a mock are handled and what you do if you want to alter the return values on subsequent calls. Consider the scenario where you have a method you’re calling that you want to be successful the first time you... Read more
In Part 4 we looked at how parameter constraints are handled and in Part 3 we looked at how to do interaction based tests with mocks. In this part we bring those two pieces together and add a little extra to check if a call was made a specific number of times. Let’s just jump straight... Read more
Continuing with our comparison of Rhino Mocks, Moq and NSubstitute we now turn our eye to how constraints are managed. Consider a method with parameters that was want to mock. By default, a mock object will only return a specified value if the parameters passed to it exactly match the call signature specified to the mock... Read more
Our comparison of Rhino Mocks, Moq and NSubstitute continues with a look at how these frameworks support interaction based testing (whether that’s a good idea or not is not going to be dealt with here!). The idea behind interaction based testing is checking if our class under test makes appropriate calls to the mocked objects. Typically... Read more
Carrying on with our Rhino Mocks, Moq and NSubstitute comparison, let’s now look at how the various frameworks handle properties on their mock objects. Rhino Mocks So in RhinoMocks you have two choices for creating mock objects – using GenerateMock<T>() or GenerateStub<T>(). GenerateMock will create a mock object that tracks calls made to it so that... Read more
I recently gave a talk on mocking at the DDD Sydney conference called “You Look Like A Monkey and You Smell Like One Too”. In it I not only got to call the audience various names and get mocked in return, but I also showed a number of features of mock frameworks and how they can... Read more
Here’s the scenario – you use ReSharper and you want to use BDD style naming in your tests. You know; that style with all those underscores in the test names so that your really long test names are actually readable. The problem is, ReSharper get’s all upset at you when you do this and throws warnings... Read more
Rhino Mocks is a great mocking framework, being seen as one of the best ones around and rightly so, however it’s syntax at times is a little verbose and clunky.A few of the guys from the Sydney Alt.Net group who work together at Cochlear got a little fed up with the syntax Rhino uses for creating... Read more
Have you ever looked at a file in the pending changes window and wanted to see what the differences were between that file and the latest version? If so, then you’ll no doubt have done the right click, sub-menu dance like this: Well, you don’t have to. There’s actually a few ways to avoid the right... Read more
I was very pleasantly surprised today when I received an email from Microsoft stating that I have been awarded MVP status for my contributions over the last year. Here’s the proof – my MVP Profile. Happy days! Read more
The Sydney Alt.Net User Group is on tomorrow night (RSVP if you’re coming!) and as we creep up on 2 years of running I was thinking about how the group is progressing. Personally I really enjoy the group. I’ve learned heaps and I love hanging out with everyone but at the same time I wonder about... Read more
This is a quick one for a few guys I was talking with today. One of the PITA things about Visual Studio 2008 / 2010 is that when you choose to have Visual Studio implement an interface for you it will generate the code inside a #region block. And why is that bad? Because regions suck!... Read more
I was talking to someone yesterday telling me about her previous employer and the scrum team they had. I almost fell over when she said they had 50 people on their team at the time. Surely that was 6 or 7 smaller teams right? No – just one team. In fact there were so many people... Read more
Put Saturday July 17th in your diaries people – it’s when DDD Sydney is on. The community run, zero cost day where you can get your fill of technical content on a whole range of Microsoft developer related topics. I’m lucky enough to have landed a speaking spot and so I’ll be doing a session on... Read more