Esempio n. 1
0
        public void HistoryDateTimeIsInUtcTest()
        {
            InjectionDateTime.SetTestDateTime();
            IConnectionHistory history      = RecordHistoryItemToFilePersistence();
            DateTime           recordedDate = GetRecordedDate(history);

            Assert.AreEqual(recordedDate, Moment.Now, "Correct date wasn't delivered to the history file");
        }
 /// <summary>
 /// Injects current UTC time as fixed constant as replacement of DateTime.UtcNow for testing purposes
 /// </summary>
 internal static void SetTestDateTime()
 {
     var moment = new PrivateType(typeof(Moment));
     var current = DateTime.UtcNow;
     // reduce precision to seconds, because Ticks may be extracted by SQL server
     DateTime precise = new DateTime(current.Year, current.Month, current.Day, current.Hour, current.Minute, current.Second);
     var customMoment = new InjectionDateTime { UtcNow = precise };
     moment.SetStaticField("service", customMoment);
 }
Esempio n. 3
0
        public void ClearHistoryTest()
        {
            this.Persistence.ConnectionHistory.HistoryClear += new Action(PrimaryHistory_HistoryClear);
            InjectionDateTime.SetTestDateTime();
            IConnectionHistory history = RecordHistoryItemToFilePersistence();

            history.Clear();
            int historyItems = history.GetDateItems(HistoryIntervals.TODAY).Count;

            Assert.AreEqual(0, historyItems, "File history wasnt clear properly");
            Assert.AreEqual(1, historyClearReported, "History clear wasnt reported properly");
        }
Esempio n. 4
0
        /// <summary>
        /// Injects current UTC time as fixed constant as replacement of DateTime.UtcNow for testing purposes
        /// </summary>
        internal static void SetTestDateTime()
        {
            var moment  = new PrivateType(typeof(Moment));
            var current = DateTime.UtcNow;
            // reduce precision to seconds, because Ticks may be extracted by SQL server
            DateTime precise      = new DateTime(current.Year, current.Month, current.Day, current.Hour, current.Minute, current.Second);
            var      customMoment = new InjectionDateTime {
                UtcNow = precise
            };

            moment.SetStaticField("service", customMoment);
        }