Пример #1
0
 /// <summary>
 /// Add a new event to our list of events to scan.
 /// </summary>
 /// <param name="newEvent">Event object to montitor daily.</param>
 public void AddEvent(ScheduledEvent newEvent)
 {
     _scheduledEvents[newEvent.Name] = newEvent;
     if (Log.DebuggingEnabled)
     {
         newEvent.IsLoggingEnabled = true;
     }
 }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
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));
        }
Пример #5
0
 /// <summary>
 /// Add this new event to our list.
 /// </summary>
 /// <param name="newEvent">New event we'd like processed.</param>
 public void AddEvent(ScheduledEvent newEvent)
 {
     _events.AddOrUpdate(newEvent.Name, newEvent);
 }