Esempio n. 1
0
        public void FiresEventWhenTimePasses()
        {
            var triggered = false;
            var se = new ScheduledEvent("test", new DateTime(2015, 08, 07), (name, triggerTime) =>
            {
                triggered = true;
            });
            se.IsLoggingEnabled = true;

            se.Scan(new DateTime(2015, 08, 06));
            Assert.IsFalse(triggered);

            se.Scan(new DateTime(2015, 08, 08));
            Assert.IsTrue(triggered);
        }
Esempio n. 2
0
        public void SchedulesNextEvent()
        {
            var first = new DateTime(2015, 08, 07);
            var second = new DateTime(2015, 08, 08);
            var dates = new[] { first, second }.ToHashSet();
            var se = new ScheduledEvent("test", dates.ToList(), (name, triggerTime) =>
            {
                dates.Remove(triggerTime);
            });

            se.Scan(first);
            Assert.IsFalse(dates.Contains(first));

            se.Scan(second);
            Assert.IsFalse(dates.Contains(second));
        }
Esempio n. 3
0
 public void NextEventTimeIsMaxValueWhenNoMoreEvents()
 {
     var time = new DateTime(2015, 08, 11, 10, 30, 0);
     var sevent = new ScheduledEvent("test", time, (n, t) => { });
     sevent.Scan(time);
     Assert.AreEqual(DateTime.MaxValue, sevent.NextEventUtcTime);
 }
Esempio n. 4
0
 public void FiresSkippedEventsInSameCallToScan()
 {
     int count = 0;
     var time = new DateTime(2015, 08, 11, 10, 30, 0);
     var sevent = new ScheduledEvent("test", new[] { time.AddSeconds(-2), time.AddSeconds(-1), time}, (n, t) => count++);
     sevent.Scan(time);
     Assert.AreEqual(3, count);
 }
Esempio n. 5
0
 public void FiresEventOnTime()
 {
     var fired = false;
     var time = new DateTime(2015, 08, 11, 10, 30, 0);
     var sevent = new ScheduledEvent("test", time, (n, t) => fired = true);
     sevent.Scan(time);
     Assert.IsTrue(fired);
 }
Esempio n. 6
0
        public void DoesNothingAfterEventsEnd()
        {
            var triggered = false;
            var first = new DateTime(2015, 08, 07);
            var se = new ScheduledEvent("test", first, (name, triggerTime) =>
            {
                triggered = true;
            });

            se.Scan(first);
            Assert.IsTrue(triggered);

            triggered = false;
            se.Scan(first.AddYears(100));
            Assert.IsFalse(triggered);
        }