Akov.DataGenerator
1.6.0
See the version list below for details.
dotnet add package Akov.DataGenerator --version 1.6.0
NuGet\Install-Package Akov.DataGenerator -Version 1.6.0
<PackageReference Include="Akov.DataGenerator" Version="1.6.0" />
paket add Akov.DataGenerator --version 1.6.0
#r "nuget: Akov.DataGenerator, 1.6.0"
// Install Akov.DataGenerator as a Cake Addin #addin nuget:?package=Akov.DataGenerator&version=1.6.0 // Install Akov.DataGenerator as a Cake Tool #tool nuget:?package=Akov.DataGenerator&version=1.6.0
DataGenerator
Generates data randomly based on
- Json file.
- Class attributes (since version 1.3).
- Fluent mapping profiles (since version 1.4).
Key features:
- Calculated properties with custom rules.
- Random failures.
Links
History
Originally this library was created in order to prepare json mocked data for testing api, which was under development. Api was supposed to aggregate data from a bunch of backend systems, while the client had to import several hundred thousand objects to a new frontend cms. It was extremely important to make sure that all data format surprises, which we were getting, could have been handled properly. That's why random failures were added to DG
. As well as random sized arrays. At the same time, it was impossible to import an object if all properties contained completely random data. This is where calculated properties hepled.
After that I didn't work with DG
for almost two years. During this time a couple of nice tools, helping out with fake data, appeared. Some time ago, I was working on the other issue, where data couldn't be too random again. I realized, that DG
may get its second chance and got back to updating it with new features, primarily focusing on building a more convenient setup, based on the fluent syntax.
DG
, at this moment, is quite far from being optimal in terms of performance as well as in code experience, test coverage or documentation. But if you see that there could be nice features added, feel free to create a github issue or discussion.
Example
// In StudentsTestProfile profile constructor
ForType<Student>()
.Ignore(s => s.HasWarnings).Ignore(s => s.IsValid)
.Ignore(s => s.ParsingErrors).Ignore(s => s.ParsingWarnings)
.Property(s => s.Id).Failure(nullable: 0.2)
.Property(s => s.FirstName).FromFile("firstnames.txt").Failure(nullable: 0.1)
.Property(s => s.LastName).FromFile("lastnames.txt").Failure(nullable: 0.1)
.Property(s => s.FullName).Assign(s => $"{s.FirstName} {s.LastName}")
.Property(s => s.Year).UseGenerator("MyUintGenerator").Range(5)
.Property(s => s.Variant).HasJsonName("test_variant")
.Property(s => s.TestAnswers).HasJsonName("test_answers").Length(5).Range(1, 5)
.Property(s => s.EncodedSolution).HasJsonName("encoded_solution")
.Pattern("abcdefghijklmnopqrstuvwxyz0123456789").Length(15, 50).Spaces(1,3)
.Failure(0.1, 0.1, 0.05, "####-####-####" )
.Property(s => s.LastUpdated).HasJsonName("last_updated").Pattern("dd/MM/yy")
.Range("20/10/19","01/01/20").Failure(0.2, 0.2, 0.1)
.Property(s => s.Subjects).Length(4);
// Execute
var dg = new DG(new StudentGeneratorFactory(), new DataSchemeMapperConfig { UseCamelCase = true });
string jsonData = dg.GenerateJson<StudentCollection>(new StudentsTestProfile());
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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 is compatible. 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 was computed. 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 | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Newtonsoft.Json (>= 12.0.3)
-
net6.0
- Newtonsoft.Json (>= 12.0.3)
-
net7.0
- Newtonsoft.Json (>= 12.0.3)
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.10.0 | 493 | 11/14/2023 | |
1.9.1 | 720 | 1/11/2023 | |
1.9.0 | 692 | 1/8/2023 | |
1.8.2 | 676 | 12/18/2022 | |
1.8.1 | 668 | 12/14/2022 | |
1.8.0 | 693 | 12/7/2022 | |
1.7.1 | 679 | 12/5/2022 | |
1.7.0 | 703 | 12/5/2022 | |
1.6.4 | 708 | 11/30/2022 | |
1.6.2 | 715 | 11/23/2022 | |
1.6.1 | 749 | 11/23/2022 | |
1.6.0 | 700 | 11/21/2022 | |
1.5.2 | 714 | 11/20/2022 | |
1.5.1 | 691 | 11/19/2022 | |
1.5.0 | 721 | 11/18/2022 | |
1.4.1 | 731 | 11/16/2022 | |
1.4.0 | 795 | 7/31/2022 | |
1.3.1 | 909 | 9/24/2020 | |
1.3.0 | 849 | 9/7/2020 | |
1.2.0 | 1,003 | 8/31/2020 |