Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > General> Overwriting CatalogName for testing with NUNit
 

Pages: 1
General
Overwriting CatalogName for testing with NUNit
Page:1/1 

  Print all messages in this thread  
Poster Message
jmcervera
User



Location:
Spain
Joined on:
03-Jun-2004 09:21:27
Posted:
27 posts
# Posted on: 20-Dec-2005 15:34:37.  
Hello everybody!
Tongue
I pretend to do unit testing of manager classes tha uses llblgen business entities, and I am having troubles with the ovewriting od the catalog to use, because I am using Adapter, and I want to use a different database for testing.
The use of the config file works when I use the application, but It doesn`t work with the config file used by NUnit (project_test.dll.config)
How can I make this in a config file?
Can somebody help give me a sample?

Thank you

Wink
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
34490 posts
# Posted on: 20-Dec-2005 17:42:13.  
I use the same setup (a dll.config file) and it works great. If the connection string can be read from the config file, so will the name overwriting settings (and tracing stuff etc.).

Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
pilotboba
User



Location:

Joined on:
05-Aug-2005 21:31:38
Posted:
434 posts
# Posted on: 20-Dec-2005 20:34:27.  
jmcervera wrote:
Hello everybody!
Tongue
I pretend to do unit testing of manager classes tha uses llblgen business entities, and I am having troubles with the ovewriting od the catalog to use, because I am using Adapter, and I want to use a different database for testing.
The use of the config file works when I use the application, but It doesn`t work with the config file used by NUnit (project_test.dll.config)
How can I make this in a config file?
Can somebody help give me a sample?

Thank you

Wink


Make sure your config file is getting coppied into the bin folder with the dll.

BOb
  Top
jmcervera
User



Location:
Spain
Joined on:
03-Jun-2004 09:21:27
Posted:
27 posts
# Posted on: 21-Dec-2005 10:25:21.  
Otis wrote:
I use the same setup (a dll.config file) and it works great. If the connection string can be read from the config file, so will the name overwriting settings (and tracing stuff etc.).


Yes Frans, it works, but I am making something wrong sometimes.

This is my case.
The name of the catalog I use when generating was "boletines", and the name of the catalog for testing is "boletines_test".

I have the dll.config file in the right folder and this works

Quote:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

    <appSettings>
        <add key="Main.ConnectionString" value="data source=localhost;initial catalog=boletines_test;integrated security=SSPI;"/>        
        <add key="CatalogNameUsageSetting" value="1" />
        <add key="CatalogNameToUse" value="boletines_test" />        
    </appSettings>

</configuration>


but this doesn`t work

Quote:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

    <configSections>
        <section name="sqlServerCatalogNameOverwrites" type="System.Configuration.NameValueSectionHandler" />
    </configSections>
    
    <sqlServerCatalogNameOverwrites>
        <add key="boletines" value="boletines_test" />
        
    </sqlServerCatalogNameOverwrites>

    <appSettings>
        <add key="Main.ConnectionString" value="data source=localhost;initial catalog=boletines_test;integrated security=SSPI;"/>        
    </appSettings>

</configuration>


In this last case I have this error:
Quote:
SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException: An exception was caught during the execution of a retrieval query: Invalid object name 'Boletines.dbo.maquinas'.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.

at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.ExecuteSingleRowRetrievalQuery(IRetrievalQuery queryToExecute, IEntityFields2 fieldsToFill, IFieldPersistenceInfo[] fieldsPersistenceInfo)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityUsingFilter(IEntityFields2 fieldsToFetch, IFieldPersistenceInfo[] persistenceInfos, IRelationPredicateBucket filter)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityUsingUniqueConstraint(IEntity2 entityToFetch, IPredicateExpression uniqueConstraintFilter)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityUsingUniqueConstraint(IEntity2 entityToFetch, IPredicateExpression uniqueConstraintFilter, Context contextToUse)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityUsingUniqueConstraint(IEntity2 entityToFetch, IPredicateExpression uniqueConstraintFilter, IPrefetchPath2 prefetchPath, Context contextToUse)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityUsingUniqueConstraint(IEntity2 entityToFetch, IPredicateExpression uniqueConstraintFilter, IPrefetchPath2 prefetchPath)
at Fichajes.BusinessObjects.FichajeMaquina.BuscarMaquina(String codigo) in FichajeMaquina.cs:line 76
at Fichajes.BusinessObjects.FichajeMaquina..ctor(String codigo) in FichajeMaquina.cs:line 26
at Fichajes.BusinessObjects.Test.FichajeMaquinaFixture.Mas() in fichajemaquinafixture.cs:line 30


It seems the query is still looking for a catalog named boletines
What am I doing wrong?

Thanks Tongue


  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
13655 posts
# Posted on: 21-Dec-2005 15:08:59.  
Please read the section Catalog specific persistence info (SqlServer specific) in the LLBLGen Pro documentation under "Using the generated code - Adapter - DataAccessAdapter Functionality"

This was copied from that section:

Adapter uses schema specific persistence information. This means that the schema name is generated into the persistence information and that the queries will use the schema name generated into the persistence information for each field and database object (table/view).

So you should overwrite the catalog name generated (as you did in the first example)
  Top
jmcervera
User



Location:
Spain
Joined on:
03-Jun-2004 09:21:27
Posted:
27 posts
# Posted on: 21-Dec-2005 15:59:15.  
I thought I was doing the same with my second code sample.

And this is explained in the manual in "Generated code - Application configuration through .config files" section. The code was copied from there.

Thanks

Juanma




  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
13655 posts
# Posted on: 22-Dec-2005 06:24:40.  
is it a Web project (ASP.NET)? if so pease note the following:

Quote:
Note: for ASP.NET applications, the section declaration has to contain in the type attribute the full type with version and culture, otherwise you'll get an exception at runtime. The specific type declaration is specific for the .NET version you're using and you can find examples how to specify it from the machine.config file in %WINDIR%\Microsoft.NET\Framework\version\CONFIG.
For example for .NET 1.1:

<configSections>
    <section name="sqlServerCatalogNameOverwrites" "sqlServerCatalogNameOverwrites" type="System.Configuration.NameValueFileSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>



is the schema name the same? for both databases? or your new catalog is in a different schema?
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
34490 posts
# Posted on: 22-Dec-2005 09:49:59.  
the names are case sensitive:

<sqlServerCatalogNameOverwrites>
<add key="boletines" value="boletines_test" />

should be


<sqlServerCatalogNameOverwrites>
<add key="Boletines" value="boletines_test" />


Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
jmcervera
User



Location:
Spain
Joined on:
03-Jun-2004 09:21:27
Posted:
27 posts
# Posted on: 23-Dec-2005 23:27:56.  
No Walaa, it's not a web project, and the schema is the same in both cases.

And I canĀ“t check it now, but I am pretty sure that Otis is right, and the problem is with the case sensivity issue.

Thank you very much
  Top
jelling
User



Location:

Joined on:
26-Oct-2007 21:37:18
Posted:
22 posts
# Posted on: 08-Nov-2007 00:05:29.  
Otis wrote:
the names are case sensitive:

    <sqlServerCatalogNameOverwrites>
        <add key="boletines" value="boletines_test" />

should be


    <sqlServerCatalogNameOverwrites>
        <add key="Boletines" value="boletines_test" />


Is there any reason the key name should be case sensitive? I don't think most database names are case-sensitive.

I just ran into this issue and it cost me about an hour.

.jelling


  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
13655 posts
# Posted on: 08-Nov-2007 11:10:25.  
A wild guess:
You may have Case-Sensetive collation database server, and you may have 2 catalogs with the same name but with different cases.
And I think LLBLGen Pro won't know about the case sensetivity of your server, at runtime.
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
34490 posts
# Posted on: 08-Nov-2007 12:03:01.  
Casing is important, because most databases are in fact case sensitive. Just because Sqlserver's default install is case insensitive doesn't mean it's always the case Wink. To serve that situation as well, the name HAS TO BE case sensitive,

Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
jelling
User



Location:

Joined on:
26-Oct-2007 21:37:18
Posted:
22 posts
# Posted on: 08-Nov-2007 17:32:24.  
Otis wrote:
Casing is important, because most databases are in fact case sensitive. Just because Sqlserver's default install is case insensitive doesn't mean it's always the case Wink. To serve that situation as well, the name HAS TO BE case sensitive,


Haha, I can live with that. All though, for once I think MS got this one right. Case sensitive DB names seem like a feature that will only cause pain. Oh well.


  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.