From: da**********@gm ail.com (CtrlAltDel)
Newsgroups: microsoft.publi c.dotnet.datato ols
Subject: Unit-testing applications that use the
Microsoft.Patte rns.EnterpriseL ibrary.Data
Date: 15 Apr 2005 08:06:31 -0700
I've written a web application that uses the M.P.E.D namespace to do
all of its data layer tasks (and a nifty bit of code M.P.E.D is too!).
However, unit-testing is proving a bit of a problem, as the database
factory complains it is unable to locate the expected
dataconfigurati on file :
1) MyBusinessObjec t.Tests.Registr ationFixture.Si mpleRegistratio n :
System.Configur ation.Configura tionException : Invalid section name.
The section 'dataConfigurat ion' does not exist in the requested
configuration file
'E:\Inetpub\www root\MyApplicat ion\MyBusinessO bject.Tests\bin \Debug\MyBusine s
sObject.Tests.d ll.config'
or the file
'c:\winnt\micro soft.net\framew ork\v1.1.4322\C onfig\machine.c onfig'.
Make sure that the 'enterpriseLibr ary.configurati onSections'
configuration section exists in one of the files and that the section
'dataConfigurat ion' is defined.
at
Microsoft.Pract ices.Enterprise Library.Configu ration.Configur ationBuilder.Va l
idateSection(St ring
sectionName)
at
Microsoft.Pract ices.Enterprise Library.Configu ration.Configur ationBuilder.Re a
dConfiguration( String
sectionName)
at
Microsoft.Pract ices.Enterprise Library.Configu ration.Configur ationContext.Ge t
Configuration(S tring
sectionName)
at
Microsoft.Pract ices.Enterprise Library.Data.Da tabaseConfigura tionView.GetDat a
baseSettings()
at
Microsoft.Pract ices.Enterprise Library.Data.Da tabaseConfigura tionView.GetDef a
ultInstanceName ()
at
Microsoft.Pract ices.Enterprise Library.Data.Da tabaseProviderF actory.GetDefau l
tInstanceName()
at
Microsoft.Pract ices.Enterprise Library.Configu ration.Provider Factory.CreateD e
faultInstance()
at
Microsoft.Pract ices.Enterprise Library.Data.Da tabaseProviderF actory.CreateDe f
aultDatabase()
at
Microsoft.Pract ices.Enterprise Library.Data.Da tabaseFactory.C reateDatabase()
at MyBusinessObjec t.Application.S ave() in
E:\Inetpub\wwwr oot\MyApplicati on\MyBusinessOb ject\Applicatio n.cs:line
96
at MyBusinessObjec t.Tests.Registr ationFixture.Si mpleRegistratio n()
in
E:\Inetpub\wwwr oot\MyApplicati on\MyBusinessOb ject.Tests\Regi strationFixture .
cs:line
90
I created an app.config and a dataconfigurati on.config in the root
directory of the unit test library, and added a post-build event to
VS.NET to copy the .config files to the bin/debug folder, and indeed
the files get copied there, but the tests are still failing. Any idea
how to unit tests apps written with the EnterpriseLibra ry?