The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Spring.net gets method injection!

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Udi Dahan

Posts: 882
Nickname: udidahan
Registered: Nov, 2003

Udi Dahan is The Software Simplist
Spring.net gets method injection! Posted: Jun 27, 2006 3:08 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Udi Dahan.
Original Post: Spring.net gets method injection!
Feed Title: Udi Dahan - The Software Simplist
Feed URL: http://feeds.feedburner.com/UdiDahan-TheSoftwareSimplist
Feed Description: I am a software simplist. I make this beast of architecting, analysing, designing, developing, testing, managing, deploying software systems simple. This blog is about how I do it.
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Udi Dahan
Latest Posts From Udi Dahan - The Software Simplist

Advertisement
You might remember my previous post on Dependency Injection Woes where I bemoaned the issue of string naming as well as the lack of method injection. Well, it turns out that the latest version of Spring.net has just added method injection.

I just wanted to mention one not-so-small issue I have with method injection - it's testability.

When using the IObjectBuilder I described in the previous post, when I wanted to test the class that needed to create a new instance of another object at runtime (it's code looking like this: "this.builder.Build();"), I could do something like this (using NUnit.Mocks):

DynamicMock builderMock = new DynamicMock(typeof(IBuilder));
DynamicMock otherObjectMock = new DynamicMock(typeof(IOtherObject));

unitUnderTest.builder = builderMock.MockInstance as IBuilder;

builderMock.ExpectAndReturn("Build", otherObjectMock.MockInstance);


And I could embellish properties and such on the created object.

With method injection, in my tests I have to subclass the unit under test and override the method. While both styles work, and I think I like the way the production code comes out with method injection better, the added weight for testing is a drag.

The law of conservation of energy will apparently always apply.

Read: Spring.net gets method injection!

Topic: Expression Graphics Designer Training Videos Previous Topic   Next Topic Topic: Expression Web Designer Training Videos

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use