/// <summary>
        /// Generates a random DateTime in the range ['minYear', 'maxYear']. This
        /// method generate dates without time(or time set to 00:00:00)
        /// </summary>
        /// <param name="min">(optional) minimum range value</param>
        /// <param name="max">max range value</param>
        /// <returns>a random DateTime value.</returns>
        public static DateTime NextDate(DateTime min, DateTime max)
        {
            var diff = RandomDouble.NextDouble(max.Subtract(min).TotalSeconds);
            var date = min.AddSeconds(diff);

            return(new DateTime(date.Year, date.Month, date.Day, 0, 0, 0, 0, min.Kind));
        }
Esempio n. 2
0
        public void TestUpdateDouble()
        {
            double value = RandomDouble.UpdateDouble(0, 5);

            Assert.True(value <= 5 && value >= -5);
            Assert.True(value == DoubleConverter.ToDouble(value));
        }
Esempio n. 3
0
        public void TestNextDouble()
        {
            double value = RandomDouble.NextDouble(5);

            Assert.True(value < 5);
            Assert.True(value == DoubleConverter.ToDouble(value));

            value = RandomDouble.NextDouble(2, 5);
            Assert.True(value < 5 && value > 2);
            Assert.True(value == DoubleConverter.ToDouble(value));
        }
        /// <summary>
        /// Generates a random DateTime and time in the range ['minYear', 'maxYear'].
        /// This method generate dates without time(or time set to 00:00:00)
        /// </summary>
        /// <param name="min">minimum range value</param>
        /// <param name="max">max range value</param>
        /// <returns>a random DateTime value.</returns>
        public static DateTime NextDateTime(DateTime min, DateTime max)
        {
            var diff = RandomDouble.NextDouble(max.Subtract(min).TotalSeconds);

            return(min.AddSeconds(diff));
        }