SqlTestPrep 1.0.3

Install-Package SqlTestPrep -Version 1.0.3
dotnet add package SqlTestPrep --version 1.0.3
<PackageReference Include="SqlTestPrep" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SqlTestPrep --version 1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SqlTestPrep, 1.0.3"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install SqlTestPrep as a Cake Addin
#addin nuget:?package=SqlTestPrep&version=1.0.3

// Install SqlTestPrep as a Cake Tool
#tool nuget:?package=SqlTestPrep&version=1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

SQLTestPrep is designed to work with unit testing frameworks to test data access classes. Working with a clean database SQLTestPrep inserts a set of data into a database before your test and then deleting the data after the test. If you configure your unit test to run the SQLTestPrep before and after each test, each of your unit tests has a clean set of known data to manipulate.

Setup is simple.

  1. Add a folder called "SqlConfiguration" to your unit test project. This folder will contain your .sql files for inserting and deleting data from the database.
  2. Add your .sql files to the SqlConfiguration folder
  3. Add configuration file named "SqlConfiguration.json" to the root of your unit test project
  4. Setup the configuration

[ { "SqlConfigurationName": "", "ConnectionString": "", "SqlConfigurationJobs": [ { "BeforeTestSqlFile": "", "AfterTestSqlFile": "", "SortOrder": "" }, { "BeforeTestSqlFile": "", "AfterTestSqlFile": "", "SortOrder": "" } ] } ]


[ { "SqlConfigurationName": "PersonTest", "ConnectionString": "Server=.;Database=Contact;User Id=contactuser;Password=password;", "SqlConfigurationJobs": [ { "BeforeTestSqlFile": "C:\repos\SqlTestPrep\SqlTestPrep.ScratchTests\SqlConfiguration\PersonTest_Setup.sql", "AfterTestSqlFile": "C:\repos\SqlTestPrep\SqlTestPrep.ScratchTests\SqlConfiguration\PersonTest_Teardown.sql", "SortOrder": "0" }, { "BeforeTestSqlFile": "C:\repos\SqlTestPrep\SqlTestPrep.ScratchTests\SqlConfiguration\PersonTest_States_Setup.sql", "AfterTestSqlFile": "C:\repos\SqlTestPrep\SqlTestPrep.ScratchTests\SqlConfiguration\PersonTest_States_Teardown.sql", "SortOrder": "1" } ] } ]

  1. In your unit test create an instance of the SqlTestPrep.SqlLoader classes
  2. Before each test call sqlLoader.Setup("<<SqlConfigurationName>>")
  3. After each test call sqlLoader.Teardown("<<SqlConfigurationName>>")

For Example

//Instantiate SqlLoader var sqlLoader = new SqlLoader();

//Call Setup before the test sqlLoader.Setup("PersonTest");

//Call Teardown before the test sqlLoader.Teardown("PersonTest");

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.3 799 10/10/2017
1.0.1 659 7/10/2017
0.1.0 669 7/10/2017

Moved config file path to appSettings.json file