Beispiel #1
0
        public void TestOverridingTheCurrentDateTime()
        {
            DateTime currentDataTime  = DateTime.Now;
            DateTime overRideDataTime = DateTimeOverride.Now;

            DateTimeTestsHelper.DateTimesAreWithIn2Seconds(currentDataTime, overRideDataTime);

            using (new DateTimeOverRideSetter(Christmas1900))
            {
                DateShouldBeChristmas1900(DateTimeOverride.Now, dateFormat);
            }

            Assert.IsFalse(DateTimeOverride.Now.ToString(dateFormat) == Christmas1900.ToString(dateFormat));
        }
Beispiel #2
0
        public void TestOverridingTheCurrentDateTimeUTC()
        {
            DateTime currentDataTime  = DateTime.UtcNow;
            DateTime overRideDataTime = DateTimeOverride.UtcNow;

            DateTimeTestsHelper.DateTimesAreWithIn2Seconds(currentDataTime, overRideDataTime);

            //Sets the current date time to be Christmas 1900
            WriteLine($"The UTC Date/Time before the using is {DateTime.UtcNow} ");
            using (new DateTimeOverRideSetterUTC(Christmas1900))
            {
                WriteLine($"The UTC Date/Time with in the using statement is Christmase 1900  {DateTimeOverride.UtcNow} ");
                DateShouldBeChristmas1900(DateTimeOverride.UtcNow, dateFormat);
            }

            WriteLine($"The UTC Date/Time after the using statement is {DateTime.UtcNow} ");
            //Once the using is complete the date time should be current date time
            var CurrentDate = DateTimeOverride.UtcNow;

            Assert.IsFalse(CurrentDate.ToString(dateFormat) == Christmas1900.ToString(dateFormat));
        }
Beispiel #3
0
 /// <summary>
 /// Check to makes sure the date time is christmas 1900
 /// </summary>
 static internal void DateShouldBeChristmas1900(DateTime currentDateIs, string dateFormat)
 {
     Assert.IsTrue(currentDateIs.ToString(dateFormat) == Christmas1900.ToString(dateFormat), $"The current date should be Christmas 1900 but it is { currentDateIs.ToString(dateFormat)}");
 }