public RandomAttribute(ulong min, ulong max, int count) { _source = new ULongDataSource(min, max, count); }
/// <summary> /// Construct a set of shorts within a specified range /// </summary> public RandomAttribute(short min, short max, int count) { _source = new ShortDataSource(min, max, count); }
/// <summary> /// Get the collection of _values to be used as arguments. /// </summary> public IEnumerable GetData(IParameterInfo parameter) { // Since a separate Randomizer is used for each parameter, // we can't fill in the data in the constructor of the // attribute. Only now, when GetData is called, do we have // sufficient information to create the values in a // repeatable manner. Type parmType = parameter.ParameterType; if (_source == null) { if (parmType == typeof(int)) { _source = new IntDataSource(_count); } else if (parmType == typeof(uint)) { _source = new UIntDataSource(_count); } else if (parmType == typeof(long)) { _source = new LongDataSource(_count); } else if (parmType == typeof(ulong)) { _source = new ULongDataSource(_count); } else if (parmType == typeof(short)) { _source = new ShortDataSource(_count); } else if (parmType == typeof(ushort)) { _source = new UShortDataSource(_count); } else if (parmType == typeof(double)) { _source = new DoubleDataSource(_count); } else if (parmType == typeof(float)) { _source = new FloatDataSource(_count); } else if (parmType == typeof(byte)) { _source = new ByteDataSource(_count); } else if (parmType == typeof(sbyte)) { _source = new SByteDataSource(_count); } else if (parmType == typeof(decimal)) { _source = new DecimalDataSource(_count); } else if (parmType.GetTypeInfo().IsEnum) { _source = new EnumDataSource(_count); } else // Default { _source = new IntDataSource(_count); } } else if (_source.DataType != parmType && WeConvert(_source.DataType, parmType)) { _source = new RandomDataConverter(_source); } return(_source.GetData(parameter)); //// Copy the random _values into the data array //// and call the base class which may need to //// convert them to another type. //this.data = new object[values.Count]; //for (int i = 0; i < values.Count; i++) // this.data[i] = values[i]; //return base.GetData(parameter); }
public RandomAttribute(uint min, uint max, int count) { _source = new UIntDataSource(min, max, count); }
public RandomAttribute(sbyte min, sbyte max, int count) { _source = new SByteDataSource(min, max, count); }
/// <summary> /// Construct a set of floats within a specified range /// </summary> public RandomAttribute(float min, float max, int count) { _source = new FloatDataSource(min, max, count); }
/// <summary> /// Construct a set of doubles within a specified range /// </summary> public RandomAttribute(double min, double max, int count) { _source = new DoubleDataSource(min, max, count); }
/// <summary> /// Retrieves a list of arguments which can be passed to the specified parameter. /// </summary> /// <param name="parameter">The parameter of a parameterized test.</param> public IEnumerable GetData(IParameterInfo parameter) { // Since a separate Randomizer is used for each parameter, // we can't fill in the data in the constructor of the // attribute. Only now, when GetData is called, do we have // sufficient information to create the values in a // repeatable manner. Type parmType = parameter.ParameterType; if (_source == null) { if (parmType == typeof(int)) { _source = new IntDataSource(_count); } else if (parmType == typeof(uint)) { _source = new UIntDataSource(_count); } else if (parmType == typeof(long)) { _source = new LongDataSource(_count); } else if (parmType == typeof(ulong)) { _source = new ULongDataSource(_count); } else if (parmType == typeof(short)) { _source = new ShortDataSource(_count); } else if (parmType == typeof(ushort)) { _source = new UShortDataSource(_count); } else if (parmType == typeof(double)) { _source = new DoubleDataSource(_count); } else if (parmType == typeof(float)) { _source = new FloatDataSource(_count); } else if (parmType == typeof(byte)) { _source = new ByteDataSource(_count); } else if (parmType == typeof(sbyte)) { _source = new SByteDataSource(_count); } else if (parmType == typeof(decimal)) { _source = new DecimalDataSource(_count); } else if (parmType.GetTypeInfo().IsEnum) { _source = new EnumDataSource(_count); } else // Default { _source = new IntDataSource(_count); } } else if (_source.DataType != parmType && WeConvert(_source.DataType, parmType)) { _source.Distinct = Distinct; _source = new RandomDataConverter(_source); } _source.Distinct = Distinct; return(_source.GetData(parameter)); }
public RandomDataConverter(RandomDataSource source) : base(source.DataType) { _source = source; }