When I run a unit test, this is the error I'm getting:
SetUp : Spring.Objects.Factory.ObjectDefinitionStoreException : Error registering object with name 'NHibernateSessionFactory' defined in 'assembly [Eiq.Middleware.Data.DomainRepository, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5c61376b85e43767], resource [Eiq.Middleware.Data.DomainRepository.Persistence.xml] line 15' : Could not resolve placeholder 'TDM.providerName'.
at Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer.ProcessProperties(IConfigurableListableObjectFactory factory, NameValueCollection props)
at Spring.Objects.Factory.Config.PropertyResourceConfigurer.PostProcessObjectFactory(IConfigurableListableObjectFactory factory)
at Spring.Context.Support.AbstractApplicationContext.InvokeObjectFactoryPostProcessors(IList objectFactoryPostProcessors, IConfigurableListableObjectFactory objectFactory)
at Spring.Context.Support.AbstractApplicationContext.InvokeObjectFactoryPostProcessors(IConfigurableListableObjectFactory objectFactory)
at Spring.Context.Support.AbstractApplicationContext.Refresh()
at Spring.Context.Support.XmlApplicationContext..ctor(XmlApplicationContextArgs args)
at Spring.Context.Support.XmlApplicationContext..ctor(String[] configurationLocations)
at Spring.Testing.NUnit.AbstractSpringContextTests.LoadContextLocations(String[] locations)
at Spring.Testing.NUnit.AbstractDependencyInjectionSpringContextTests.LoadContextLocations(String[] locations)
at Spring.Testing.NUnit.AbstractSpringContextTests.GetContext(Object key)
at Spring.Testing.NUnit.AbstractDependencyInjectionSpringContextTests.SetUp()
Is there any way I could get it to somehow pass in the value for "TDM.providerName" by setting something in my unit test app.config? This is what I have tried, but it did not help, where the name of the test project is MiddlewareTests, and the default namespace is Eiq.Middleware.SmokeTest:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="databaseProperties" type="System.Configuration.NameValueSectionHandler, System" />
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core" />
<section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core" />
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" restartOnExternalChanges="true" />
</sectionGroup>
</configSections>
<appSettings>
<add key="DefaultUserName" value="tdmuser" />
<!-- Well Query Limit -->
<add key="WellQueryLimit" value="50000" />
<add key="TDM.providerName" value="SqlServer-2.0"/>
</appSettings>
<spring>
<parsers>
<parser type="Spring.Data.Config.DatabaseNamespaceParser, Spring.Data" />
<parser type="Spring.Transaction.Config.TxNamespaceParser, Spring.Data" />
<parser type="Spring.Aop.Config.AopNamespaceParser, Spring.Aop" />
</parsers>
<context>
<resource uri="assembly://MiddlewareTests/Eiq.Middleware.SmokeTest/Persistence.xml" />
<resource uri="assembly://MiddlewareTests/TEiq.Middleware.SmokeTest/Repositories.xml" />
<resource uri="assembly://MiddlewareTests/Eiq.Middleware.SmokeTest/Services.xml" />
<resource uri="config://spring/objects" />
</context>
<objects configSource="config\spring.config" />
</spring>
</configuration>
Or, alternatively, how could I get the application to point to copies of Persistence.xml, Repositories.xml, and Services.xml files that I have modified for testing directly in my unit testing project? Does anyone have any other suggestions?
To resolve the above issue, performed several steps, though I'm not sure specifically which one fixed it:
Also, updated the App.config file in my test project to the following, with they key parts being those related to hibernate-configuration:
HTH.