Пример #1
0
        private async Task FuzzGenerator(int iterations, int bytesPerRequestMin, int bytesPerRequestMax, IRandomNumberGenerator generator, string filename)
        {
            var rng = new StandardRandomWrapperGenerator();

            using (var sw = new StreamWriter(filename + ".txt", false, Encoding.UTF8))
            {
                await sw.WriteLineAsync($"{generator.GetType().FullName} - {iterations:N0} iterations");

                for (int i = 0; i < iterations; i++)
                {
                    var bytesToGet = rng.GetRandomInt32(bytesPerRequestMin, bytesPerRequestMax);
                    var bytes      = generator.GetRandomBytes(bytesToGet);
                    if (bytes == null)
                    {
                        await sw.WriteLineAsync("<null>");
                    }
                    else
                    {
                        await sw.WriteLineAsync(bytes.ToHexString());
                    }
                }
            }
        }