public override object?Generate(IFuzzProfile profile, Type type, FuzzRandom random) { var constructor = random.Choice(type.GetConstructors()); var arguments = constructor.GetParameters() .Select(p => profile.Generate(p.ParameterType, random)); return(constructor.Invoke(arguments.ToArray())); }
public override object?Generate(IFuzzProfile profile, Type type, FuzzRandom random) { // Only find direct subclasses. Indirect subclasses can be found recursively var candidateClasses = DirectSubclassesOf(type) .ToList(); var generatedType = random.Choice(candidateClasses); return(profile.Generate(generatedType, random)); }
public override object?Generate(IFuzzProfile profile, Type type, FuzzRandom random) { Check.IsTrue(type.IsEnum); return(random.Choice(type.GetEnumValues())); }
public override object?Generate(IFuzzProfile profile, Type type, FuzzRandom random) { return(random.Choice(_items)); }