Ejemplo n.º 1
0
 /// <summary>
 /// Generates <see cref="double"/> values within a specified range.
 /// </summary>
 public RandomAttribute(double min, double max, int count)
 {
     _source = new DoubleDataSource(min, max, count);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Generates <see cref="ulong"/> values within a specified range.
 /// </summary>
 public RandomAttribute(ulong min, ulong max, int count)
 {
     _source = new ULongDataSource(min, max, count);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Generates <see cref="ushort"/> values within a specified range.
 /// </summary>
 public RandomAttribute(ushort min, ushort max, int count)
 {
     _source = new UShortDataSource(min, max, count);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Generates <see cref="uint"/> values within a specified range.
 /// </summary>
 public RandomAttribute(uint min, uint max, int count)
 {
     _source = new UIntDataSource(min, max, count);
 }
Ejemplo n.º 5
0
 public RandomDataConverter(RandomDataSource source) : base(source.DataType)
 {
     _source = source;
 }
Ejemplo n.º 6
0
        /// <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(ParameterInfo 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));
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Generates <see cref="sbyte"/> values within a specified range.
 /// </summary>
 public RandomAttribute(sbyte min, sbyte max, int count)
 {
     _source = new SByteDataSource(min, max, count);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Generates <see cref="float"/> values within a specified range.
 /// </summary>
 public RandomAttribute(float min, float max, int count)
 {
     _source = new FloatDataSource(min, max, count);
 }