Skip to content
akovanev edited this page Nov 18, 2022 · 24 revisions

Setup

Install Akov.DataGenerator NuGet package.

dotnet add package Akov.DataGenerator

Usage

Akov.DataGenerator library helps to generate random data based on its internal DataScheme.

There are three main ways how the DataScheme can be obtained.

The DG output for the first two can then be represented as a json string or a generic object.

string GenerateJson(DataScheme scheme)
T GenerateObject<T>(DataScheme scheme)

When dealing with profiles there is no public method populating the DataScheme. Instead you can directly get the output.

string GenerateJson<T>(DgProfileBase profile)
T GenerateObject<T>(DgProfileBase profile)

What should you be aware of?

At this moment, object generation is literally deserialization of the built json.

Json first approach was chosen to introduce Random Failure feature. If it is enabled, then the generated json is supposed to be invalid/incorrect for some objects, and deserialization may fail unless specific error handling is added. Like in this example based on Newtonsoft.Json usage. Unfortunately, System.Text.Json doesn't support this behavior yet.

Clone this wiki locally