.net and other musings

Ben Lovell, an agile developer living in the UK.

Incremental development with Monorail: Part Five

with 4 comments

Welcome back. In this post I’ll be getting our tests passing again and cleaning things up a little. We left off with a failing integration test:

42

I suspect this is due to the IBlogPostMapper dependency we introduced to our BlogPostService not being handled by the container. If we run in the browser we can confirm this is in fact true:

As we’ve yet to implement our IBlogPostMapper we must go ahead and do this before we can add the container configuration to pass our integration test. Lets bust out a test and get things rolling:

43

We have a few blanks to fill in in order to get this to compile and run:

  1. Make the DTO’s properties virtual so we can mock them. This is in preference to extracting an interface.
  2. Implement IBlogPostMapper.
  3. Add the necessary properties to the IBlogPost interface.

Lets go ahead and do this now:

44

IBlogPostMapper minimal implementation:

45 

The necessary modifications to IBlogPost:

46

Now we can compile and run our test:

47

Our BlogPostMapper implementation is throwing an exception so lets go back and take another step to try and pass our test:

48

BlogPost:

49

I’m pretty certain we’ve done enough to pass our test now. Lets have a go:

50

OK now lets focus on the full suite:

51

Our integration test is still bombing but as we’ve got a mapper now, we can go ahead and wire up our Windsor configuration and get things moving again:

52

We’ve added another configuration file: mapper.config and referenced this from the web.config. We shouldn’t need to do any more than this so lets run our full test suite:

53

Our full suite is passing now. Not bad for 5 minutes work! As usual the latest changes are checked in to the Google code project hosted here.

Now we have a full passing suite, in our next edition I’ll be moving down into the persistence and also incorporating a few modifications from Hammett. Stay tuned!

Written by benl

April 24, 2008 at 8:20 pm

4 Responses

Subscribe to comments with RSS.

  1. Hi Ben,

    Thanks for those great articles :)

    Would you agree that I post french translations of them on my blog ? With credits to you of course :)

    Cheers,

    Gildas

    Gildas

    April 25, 2008 at 8:30 am

  2. Hi Gildas, thanks for your comments. You can post translations of any of the content here, I just ask you link back to the original post. Let me know when you’re done and I’ll link to you from here.

    benl

    April 25, 2008 at 10:28 am

  3. hi there:

    I think this is a great series of article, please keep it up, and the way you explain things is fantastic very simple and thorough
    would you not agree that it s a good idea to add a BaseController where you do your CRUD

    something like:

    public class ControllerCRUD : SmartDispatcherController
    {
    public void List()
    {

    }

    public void Add()
    {

    }
    }

    and then you inherit from that all your controllers?
    also, do you think is a good idea to “add” the way you are adding?

    if you are planing to use persistence and I m pretty sure you are going to be using AR for it is all that structure necessary?
    Cheers
    Andrea

    Andrea

    April 25, 2008 at 4:19 pm

  4. Hi Andrea,

    Yes of course once there are other controllers I will probably extract a common base class for this kind of functionality. However, you’re missing the point of my approach. At this stage we’re not making any assumptions about what we (think) we need, we’re doing the most simple steps to pass our tests. The common parlance for this is YAGNI or “you aren’t gonna need it”.

    Of course, since we have a good suite of tests, we can confidently make these refactorings later when we need to. That is the whole point of TDD and the approach i’m taking! Thanks for your comments.

    BenL

    April 25, 2008 at 4:31 pm


Leave a Reply