public static object RandomSimpleObject() { var obj = new RandomObjectClass { TheInteger = r.Next(), TheString = new string(Enumerable.Repeat(chars, 8).Select(s => s[r.Next(s.Length)]).ToArray()), TheIntArray = new int[ARRAY_SIZE], TheObject = null }; for (var i = 0; i < ARRAY_SIZE; i++) { obj.TheIntArray[i] = r.Next(); } return(obj); }
public static object RandomObjectOfSize(int sizeInBytes) { var obj = new RandomObjectClass(); obj.TheInteger = r.Next(); obj.TheObject = null; var halfSize = (sizeInBytes - sizeof(int)) / 2; var intCount = halfSize / sizeof(int); var stringCount = halfSize / sizeof(char); obj.TheString = new string(Enumerable.Repeat(chars, stringCount).Select(s => s[r.Next(s.Length)]).ToArray()); obj.TheIntArray = new int[intCount]; for (var i = 0; i < intCount; i++) { obj.TheIntArray[i] = r.Next(); } return(obj); }