Class AvroRandomData
Random values of a schema, for property tests and fuzz corpora, as Apache Avro Java's RandomData makes them.
The same seed and options give the same values, on every target framework.
[SuppressMessage("Security", "CA5394:Do not use insecure randomness", Justification = "Test data, not secrets: the values must repeat for a seed, which a secure generator can't do.")]
public sealed class AvroRandomData
- Inheritance
-
AvroRandomData
- Inherited Members
Examples
foreach (var value in AvroRandomData.Generate(schema, seed: 42).Take(100))
{
...
}
Remarks
Every value can be written with the schema, and logical values are valid: decimals fit their precision, times are within a day, UUIDs are well formed, and dates and timestamps stay in .NET's range unless LogicalValuesInDotNetRange is off. Numbers mix small and large magnitudes; floating-point values are finite. Strings mix ASCII, accented letters, CJK and emoji (characters outside the Basic Multilingual Plane).
A recursive schema ends at MaxDepth. Once a value holds 10,000 values, the arrays and maps it starts after that are empty and its unions end as soon as they can, so a schema whose records branch out stays small. A schema with no finite value, such as a record that contains itself outside a union, array or map, is an error.
An instance is not thread-safe.
Constructors
- AvroRandomData(int, AvroRandomDataOptions?)
Initializes a generator.
Methods
- Generate(AvroSchema, int, AvroRandomDataOptions?)
Generates values of a schema, without end; take as many as needed.
- Next(AvroSchema)
Generates the next value of a schema.