Esempio n. 1
0
        public void it_should_determine_if_the_date_is_in_the_future()
        {
            Assert.True(_nowAdapter.DateTimeNow().AddYears(1).IsFuture());
            Assert.True(_nowAdapter.DateTimeNow().AddMonths(1).IsFuture());
            Assert.True(_nowAdapter.DateTimeNow().AddDays(1).IsFuture());
            Assert.True(_nowAdapter.DateTimeNow().AddHours(1).IsFuture());
            Assert.True(_nowAdapter.DateTimeNow().AddMinutes(1).IsFuture());
            Assert.True(_nowAdapter.DateTimeNow().AddSeconds(1).IsFuture());
            Assert.True(_nowAdapter.DateTimeNow().AddMilliseconds(1).IsFuture());

            Assert.False(_nowAdapter.DateTimeNow().AddYears(-1).IsFuture());
            Assert.False(_nowAdapter.DateTimeNow().AddMonths(-1).IsFuture());
            Assert.False(_nowAdapter.DateTimeNow().AddDays(-1).IsFuture());
            Assert.False(_nowAdapter.DateTimeNow().AddHours(-1).IsFuture());
            Assert.False(_nowAdapter.DateTimeNow().AddMinutes(-1).IsFuture());
            Assert.False(_nowAdapter.DateTimeNow().AddSeconds(-1).IsFuture());
            Assert.False(_nowAdapter.DateTimeNow().AddMilliseconds(-1).IsFuture());
        }
Esempio n. 2
0
        public void it_should_add_1_year_to_now()
        {
            DateTime actual   = 1.Year().FromNow();
            DateTime expected = _nowAdapter.DateTimeNow().AddYears(1);

            Assert.That(actual, Is.EqualTo(expected));
        }
Esempio n. 3
0
 /// <summary>
 /// Determines whether or not the DateTime occurs in the future.
 /// </summary>
 /// <param name="dateTime">DateTime evaluation target.</param>
 /// <returns>True if the DateTime occurs in the future.</returns>
 public static bool IsFuture(this DateTime dateTime)
 {
     return(_nowAdapter.DateTimeNow() < dateTime);
 }
Esempio n. 4
0
 /// <summary>
 /// Tomorrow's Date.
 /// </summary>
 /// <returns>Tomorrow's date value 24 hours from now.</returns>
 public static DateTime Date()
 {
     return(_nowAdapter.DateTimeNow().Date.AddDays(1));
 }
Esempio n. 5
0
 /// <summary>
 /// Calculates the result of DateTimeComponents added to DateTime.Now().
 /// </summary>
 /// <param name="components"><see cref="DateTimeComponents"/> operand.</param>
 /// <returns>Future DateTime calculated from DateTime.Now().</returns>
 public static DateTime FromNow(this DateTimeComponents components)
 {
     return(components.From(_nowAdapter.DateTimeNow()));
 }
Esempio n. 6
0
 /// <summary>
 ///	Resets the time portion of the DateTime to 00:00:00.
 /// </summary>
 /// <param name="dateTime">DateTime evaluation target.</param>
 /// <returns>Given date value at 00:00:00.</returns>
 public static DateTime AtMidnight(this DateTime dateTime)
 {
     //return dateTime.AtBeginningOfDay();
     return(_nowAdapter.DateTimeNow().AtBeginningOfDay());
 }