Exemple #1
0
 public void GetRandomDateTimeTest2()
 {
     for (var i = 0; i < 1000; i++)
     {
         var actual = RandomValueEx.GetRandomDateTime();
         Assert.True(actual >= new DateTime(1753, 01, 01) && actual <= new DateTime(9999, 12, 31));
     }
 }
        public void FirstDayOfWeekTest()
        {
            var dateTime = RandomValueEx.GetRandomDateTime();
            var expected =
                new DateTime(dateTime.Year, dateTime.Month, dateTime.Day).AddDays(-(Int32)dateTime.DayOfWeek);
            var actual = dateTime.FirstDayOfWeek();

            Assert.Equal(expected, actual);
        }
        public void EndOfYearTest()
        {
            var dateTime = RandomValueEx.GetRandomDateTime(DateTime.Now, new DateTime(3000, 1, 1));
            var expected = new DateTime(dateTime.Year, 1, 1).AddYears(1)
                           .Subtract(1.ToMilliseconds());
            var actual = dateTime.EndOfYear();

            Assert.Equal(expected, actual);
        }
Exemple #4
0
        public void GetRandomDateTimeTest4()
        {
            var max = DateTime.Now.AddDays(100);

            for (var i = 0; i < 10000; i++)
            {
                var actual = RandomValueEx.GetRandomDateTime(max: max);
                Assert.True(actual >= new DateTime(1753, 01, 01) && actual <= max);
            }
        }
Exemple #5
0
        public void GetRandomDateTimeTest3()
        {
            var min = DateTime.Now.Subtract(1.ToDays());

            for (var i = 0; i < 10000; i++)
            {
                var actual = RandomValueEx.GetRandomDateTime(min);
                Assert.True(actual >= min && actual <= new DateTime(9999, 12, 31));
            }
        }
        public void SaveToDateTimeWithDefaultTest()
        {
            var expected = DateTime.Now;
            var actual   = expected.ToString(CultureInfo.CurrentCulture)
                           .SaveToDateTime(RandomValueEx.GetRandomDateTime());

            actual
            .Should()
            .BeCloseTo(expected, 999);
        }
Exemple #7
0
        public void GetRandomDateTimeTest()
        {
            var min = DateTime.Now.Subtract(1.ToDays());

            for (var i = 0; i < 10000; i++)
            {
                var max = DateTime.Now.AddDays(i);

                var actual = RandomValueEx.GetRandomDateTime(min, max);
                Assert.True(actual >= min && actual <= max);
            }
        }