Connection strings & "how to test" questions

Posts   
 
    
Diego
User
Posts: 15
Joined: 06-Jul-2005
# Posted on: 08-Dec-2005 18:58:36   

Hello.

I'm writting an application with LLBL using the adapter scenario. My application use a ClassLibrary project called "Services" which has references to the projects generated by LLBL. This "Services" project have some classes with methods that use the adapter class (to create the instances of the adapter I'm using the default Ctor).

Now, I want to test these methods, but I want the data produced by the tests in another database with the same schema of the original database.

To accomplish this, I create another project called "Tests". This project is a Console one and it has references to nunit and to the three others project ("Services" and the two generated by LLBL).

My idea was to use the app.config file of the "Tests" project to specify a different connection string (referencing the "testing purposes database").

However, when I run my tests using Nunit, the data is stored in the original database and not in the "testing purposes database".

Is this right or is a bug of the LLBL?

If is not a bug, is there another way to test the "Services" project using NUnit, LLBL and a "testing purposes database" without changing the code of the "Services" project?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 08-Dec-2005 19:15:17   

use testassembly.dll.config to store your configs for unittests. Those then should be picked up by nunit.

Frans Bouma | Lead developer LLBLGen Pro
Diego
User
Posts: 15
Joined: 06-Jul-2005
# Posted on: 09-Dec-2005 11:59:26   

Otis wrote:

use testassembly.dll.config to store your configs for unittests. Those then should be picked up by nunit.

Ok, I tried It, but is still using the connection string from the original database and not the connection string specified in the testassembly.dll.config file. In fact I added some others settings to my testassembly.dll.config file and I can view and access them in my tests (even the connectionstring setting), however, the adapter.Save method is still persisting the entities in the original database.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 09-Dec-2005 13:17:37   

The database(catalog) name is stored inside the persistence info. (Database specific code) The reason for that is that you may have multiple catalogs in your project.

So this should work if the test database has the same name as the original database but it's located in a different database server (instance). By changing the connection string to point to the other location of the database.

If you want to modify the catalog to target with the code at runtime, please specify name overwriting settings, as discussed in DataAccessAdapter functionality, for sqlserver and Application configuration through .config files

Please refer to The LLBLGen Pro documentation-> "Using the generated code - Adapter DataAccessAdapter Functionality" ->"Catalog specific persistence info (SqlServer specific)" inside

Diego
User
Posts: 15
Joined: 06-Jul-2005
# Posted on: 09-Dec-2005 17:06:15   

Ok, I tried it and it works!!!

I ended up using what is on the "Generated code - Application configuration through .config files" chapter in the LLBL documentation.

Thanks for the help!