private object GenerateValue(Type type) { var value = type.IsCollection() ? _generatorBuilder.Get(type.GetGenericTypeDefinition()).GenerateCollection(type) : _generatorBuilder.Get(type).Generate(); if (value == null && type.IsDto() && !_previousTypes.Contains(type)) { value = new DtoInitializer(type, _generatorBuilder, _previousTypes).Create(); } return(value); }
public ICollection Generate(Type type) { var length = _random.Next(MIN_LENGTH, MAX_LENGTH); var generator = _generatorsBuilder.Get(type); var listType = GeneratedType.MakeGenericType(type); var result = (IList)Activator.CreateInstance(listType); for (var i = 0; i < length; ++i) { result.Add(generator.Generate()); } return(result); }