TDD with EntLib

Topics: Enterprise Library Core, Logging Application Block
Jan 6, 2010 at 5:23 PM

Hey guys,

I am introducing EntLib into a brownfield application. I would like to take advantage of TDD approach but having trouble understanding how would I create a test configuration for LAAB.  Web.config and app.config are not available to unit test projects b/c they are dlls.  LAAB blows up w/o IConfigurationSource set up.

Jan 6, 2010 at 9:15 PM


Are you using the Unit testing framework that comes from Visual Studio?

Valiant Dudan
Global Technology & Solutions
Avanade, Inc.

Jan 6, 2010 at 11:27 PM
Edited Jan 6, 2010 at 11:38 PM

Unfotunately, we are only using VS 2008 Standard, so I do not have an option to use MSTest.  Thus, I am using mbUnit/Gallio with RhinoMocks.  How would I intercept and inject configuration into DAAB at unit testing run time?

Also, I am using EntLib 3.1 and not 4.x

Jan 7, 2010 at 6:56 AM

I would recommend looking at the entlib unit tests, even if you can't run them. We had to do exactly what you need to do - set up configuration sources without using files. Basically, you need to create a DictionaryConfigurationSource, create the appropriate configuration sections, and add them to the configuration source.

It's a pain, and a major motivator for many of the changes we've made in Entlib 5, which makes testing and DI much, much simpler. I'd recommend looking at Entlib 5 if you get the chance.


Jan 7, 2010 at 8:05 AM

Chris, thank you for your reply. I will start there and see if I can re-use some unit test code from the 3.1 source.

Also, I did peak at entlib 5 guide and i like the DI container approach.  If in 2005, we were in JavaScript age, now we're hitting DI age ;)

Jan 29, 2010 at 12:49 AM

I am trying to overcome exact same issue. We are using VS2008 Test Edition and are working with MSTEST. We are referencing EntLib 2.0 DAAB but could upgrade it if necessary. Do you have any other suggestions or we still need to need to create a DictionaryConfigurationSource? - Gregory.