示例#1
0
 /// <summary>
 /// TimeSpan data generator that generates sequence of TimeSpan values
 /// with the specified step and starting with the specified initial value.
 /// </summary>
 /// <param name="initialValue">The initial value.</param>
 /// <param name="step">The step for the sequence.</param>
 /// <returns>TimeSpan data generator.</returns>
 public static IDataGenerator <TimeSpan> TimeSpanSequence(TimeSpan initialValue, TimeSpan step)
 {
     return(new DelegatedSeededDataGenerator <TimeSpan>(
                initialValue.Ticks,
                FromSeedStrategies.TimeSpanFromSeed(),
                TryGetNextSeedStrategies.SequenceWithStep(step.Ticks)));
 }
示例#2
0
 /// <summary>
 /// DateTimeOffset data generator that generates sequence of DateTimeOffset values
 /// with 0 offset, with the specified step and starting with the specified initial value.
 /// </summary>
 /// <param name="initialValue">The initial value.</param>
 /// <param name="step">The step for the sequence.</param>
 /// <param name="offset">The offset for the DateTimeOffset values.</param>
 /// <returns>DateTime data generator.</returns>
 public static IDataGenerator <DateTimeOffset> DateTimeOffsetSequence(DateTime initialValue, TimeSpan step, TimeSpan offset)
 {
     return(new DelegatedSeededDataGenerator <DateTimeOffset>(
                initialValue.Ticks,
                FromSeedStrategies.DateTimeOffsetFromSeed(offset),
                TryGetNextSeedStrategies.SequenceWithStep(step.Ticks)));
 }
示例#3
0
        /// <summary>
        /// Sequential data generator with unlimited capacity: generates repeated sequence starting from the seed and incrementing by the step
        /// Limit value is based on the data type.
        /// </summary>
        /// <typeparam name="TData">The type of the data.</typeparam>
        /// <param name="initialSeed">The initial seed of the generator</param>
        /// <param name="step">The amount to increment by</param>
        /// <returns>Sequential data generator with unlimited capacity.</returns>
        public static IDataGenerator <TData> RepeatedSequence <TData>(long initialSeed, long step)
        {
            long limit;

            if (!seedLimits.TryGetValue(typeof(TData), out limit))
            {
                limit = long.MaxValue;
            }

            return(new DelegatedSeededDataGenerator <TData>(
                       initialSeed,
                       FromSeedStrategies.ConvertSeed <TData>(),
                       TryGetNextSeedStrategies.RepeatedSequence(initialSeed, limit, step)));
        }
示例#4
0
 /// <summary>
 /// Sequential data generator that generates sequence starting from the seed converts it to the targeted type.
 /// </summary>
 /// <typeparam name="TData">The data type. Convertion using IConvertible must be supported from long to this type.</typeparam>
 /// <param name="initialSeed">The initial seed of the generator</param>
 /// <returns>Sequential data generator.</returns>
 public static IDataGenerator <TData> Sequence <TData>(long initialSeed)
 {
     return(new DelegatedSeededDataGenerator <TData>(
                initialSeed,
                FromSeedStrategies.ConvertSeed <TData>()));
 }
示例#5
0
 /// <summary>
 /// Binary data generator that generates sequence of values based on the sequence of seeds 1, 2, 3
 /// where seed is converted to byte[] representation with the length in the specified range.
 /// </summary>
 /// <param name="minLength">The minimum length.</param>
 /// <param name="maxLength">The maximum length.</param>
 /// <returns>Binary data generator.</returns>
 public static IDataGenerator <byte[]> BinarySequence(int minLength, int maxLength)
 {
     return(new DelegatedSeededDataGenerator <byte[]>(1, FromSeedStrategies.BinaryFromSeed(minLength, maxLength)));
 }
示例#6
0
 /// <summary>
 /// String data generator that generates sequence of values based on the sequence of seeds 1, 2, 3
 /// where seed is converted to string with the length in the specified range.
 /// </summary>
 /// <param name="minLength">The minimum length.</param>
 /// <param name="maxLength">The maximum length.</param>
 /// <returns>String data generator.</returns>
 public static IDataGenerator <string> StringSequence(int minLength, int maxLength)
 {
     return(new DelegatedSeededDataGenerator <string>(1, FromSeedStrategies.StringFromSeed(minLength, maxLength)));
 }
示例#7
0
 /// <summary>
 /// Boolean data generator that alternates between true and false, using true for odd seed values
 /// </summary>
 /// <returns>Boolean data generator</returns>
 public static IDataGenerator <bool> BooleanAlternatingSequence()
 {
     return(new DelegatedSeededDataGenerator <bool>(1, FromSeedStrategies.TrueForOdd()));
 }
示例#8
0
 /// <summary>
 /// Binary data generator that generates binary representation of strings
 /// in the sequence "1", "2", "3", ... .
 /// </summary>
 /// <returns>Binary data generator.</returns>
 public static IDataGenerator <byte[]> BinarySequence()
 {
     return(new DelegatedSeededDataGenerator <byte[]>(1, FromSeedStrategies.BinaryFromSeedAsString()));
 }