StrangerData.SqlServer
101.0.1
dotnet add package StrangerData.SqlServer --version 101.0.1
NuGet\Install-Package StrangerData.SqlServer -Version 101.0.1
<PackageReference Include="StrangerData.SqlServer" Version="101.0.1" />
paket add StrangerData.SqlServer --version 101.0.1
#r "nuget: StrangerData.SqlServer, 101.0.1"
// Install StrangerData.SqlServer as a Cake Addin #addin nuget:?package=StrangerData.SqlServer&version=101.0.1 // Install StrangerData.SqlServer as a Cake Tool #tool nuget:?package=StrangerData.SqlServer&version=101.0.1
StrangerData - A .NET database populator for testing purposes
Project Description
StrangerData is a tool designed to automatically fills your database with random data to make your unit/integration tests faster.
The generator will auto maps all foreign keys and generates records to related tables.
Getting Started
- Install StrangerData with NuGet Package Manager:
Install-Package StrangerData
- Install your database dialect, example:
Install-Package StrangerData.SqlServer
- Configure the required connection strings.
To start generating your test data, create a new DataFactory object:
using StrangerData;
using StrangerData.SqlServer;
...
var dataFactory = new DataFactory<SqlServerDialect>("MyConnectionString");
Usage
Consider the example schema:
Person Table
Column | Data Type | PK | FK |
---|---|---|---|
Id | INT | True | False |
Name | VARCHAR(20) | False | False |
VARCHAR(50) | False | False | |
Age | INT | False | False |
TeamId | INT | False | Team(Id) |
Team Table
Column | Data Type | PK | FK |
---|---|---|---|
Id | INT | True | False |
Name | VARCHAR(20) | False | False |
1. Creates a single record:
...
IDicionary<string, object> record = dataFactory.CreateOne("dbo.Person");
The method will creates an record in the group table, and associates it to the created user. The dictionary will contains:
{
"Id": "Generated User's Id",
"Name": "Random string",
"Email": "Random string",
"Age": "Random integer number",
"TeamId": "Id from generated group record"
}
So you can specify your custom values. Do following:
User user = dataFactory.CreateOne("dbo.Person", t => {
t.WithValue("Name", "Will Byers");
});
The dictionary will contains:
{
"Id": "Generated User's Id",
"Name": "Will Byers",
"Email": "Random string",
"Age": "Random integer number",
"TeamId": "Id from generated group record"
}
2. Delete generated records:
To delete all generated records, just run:
...
dataFactory.TearDown();
...
We suggest to use the TearDown() method inside yor Finally scope. This way it will run even if you code crashes on running, avoiding to have dirty data on your database.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net452 is compatible. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.5.2
- StrangerData (>= 101.0.1)
- System.Data.SqlClient (>= 4.8.6)
-
.NETStandard 2.0
- StrangerData (>= 101.0.1)
- System.Data.SqlClient (>= 4.8.6)
- System.Linq (>= 4.3.0)
-
net8.0
- Microsoft.Data.SqlClient (>= 5.1.5)
- StrangerData (>= 101.0.1)
- System.Linq (>= 4.3.0)
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 |
---|---|---|
101.0.1 | 299 | 12/6/2024 |
101.0.0 | 3,940 | 2/8/2024 |
100.0.1 | 29,069 | 3/23/2021 |
100.0.0 | 562 | 3/19/2021 |
99.99.99 | 22,061 | 10/31/2017 |
1.0.64 | 2,719 | 5/27/2017 |
1.0.63 | 1,198 | 3/8/2017 |
1.0.62 | 1,142 | 2/17/2017 |
1.0.45 | 1,071 | 1/9/2017 |
1.0.42 | 1,037 | 1/9/2017 |
1.0.39 | 1,174 | 10/13/2016 |
1.0.37 | 1,058 | 10/13/2016 |
1.0.35 | 1,095 | 10/7/2016 |
0.0.11 | 1,386 | 9/20/2016 |
0.0.10 | 1,117 | 8/25/2016 |
0.0.9 | 1,591 | 8/1/2016 |
0.0.8 | 1,365 | 7/26/2016 |
0.0.7 | 1,181 | 7/26/2016 |