For many years, we used the following code to set up databases in the base class for our functional tests for our DAL, and it worked very well for us.
However, using the Entity Framework does not install all the database components, and we would like to catch the inconsistencies between our EF DAL model and the actual database.
We use the SSDT tools / Visual Studio Database Project for all our work with the database, and I know that you can write SQL unit tests, and in these tests of SQL modules I saw the ability to configure and create a database based on the project itself Database. This is what I would like to do, but from our other functional test libraries.
I can reference libraries and write some of the installation code, but I'm looking for:
a) How to specify which database project to use for deployment?
b) How can I specify the connection string in the code and not app.config, for example, using localdb instead of a dynamically named database?
namespace Product.Data.Tests { using Microsoft.Data.Tools.Schema.Sql.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting; [TestClass] public class FunctionalTest { [TestInitialize] public virtual void TestInitialize() { SqlDatabaseTestClass.TestService.DeployDatabaseProject(); SqlDatabaseTestClass.TestService.GenerateData(); } } }
The app.config application in the SQL Unit Test project does not contain references to the original database project used to create it, and decompiles part of the test code and sees how it works, I do not see any indication. Does the solution assume there is only one database project?
c # unit-testing visual-studio entity-framework ssdt
David Anderson - DCOM
source share