Ejemplo n.º 1
0
        public void ShouldScheduleSeveralEventsWhenModuleIsRunning()
        {
            MockedAtModule module;

            DateTime[] events;
            DateTime   now;

            module = new MockedAtModule();
            Assert.AreEqual(true, module.Start());

            now    = DateTime.Now;
            events = new DateTime[] { now.AddMilliseconds(1000), now.AddMilliseconds(1100), now.AddMilliseconds(1200), now.AddMilliseconds(1300), now.AddMilliseconds(1400), now.AddMilliseconds(1500) };
            foreach (DateTime ev in events)
            {
                module.Add(ev, ev);
            }

            Thread.Sleep(2000);
            Assert.AreEqual(events.Length, module.Events.Count);
            for (int t = 0; t < module.Events.Count; t++)
            {
                Assert.AreEqual(events[t], module.Events[t]);
            }

            Assert.AreEqual(true, module.Stop());
        }
Ejemplo n.º 2
0
        public void ShouldPriorizeEventsWhenModuleIsRunning()
        {
            MockedAtModule module;

            DateTime[] events, orderedEvents;
            DateTime   now;

            module = new MockedAtModule();
            Assert.AreEqual(true, module.Start());

            now    = DateTime.Now;
            events = new DateTime[] { now.AddMilliseconds(1000), now.AddMilliseconds(1500), now.AddMilliseconds(1400), now.AddMilliseconds(1200), now.AddMilliseconds(1300), now.AddMilliseconds(1100) };
            foreach (DateTime ev in events)
            {
                module.Add(ev, ev);
            }

            orderedEvents = events.OrderBy((item) => item).ToArray();
            Thread.Sleep(2000);
            Assert.AreEqual(events.Length, module.Events.Count);
            for (int t = 0; t < module.Events.Count; t++)
            {
                Assert.AreEqual(orderedEvents[t], module.Events[t]);
            }

            Assert.AreEqual(true, module.Stop());
        }
Ejemplo n.º 3
0
        public void ShouldQuitGracefullyWhenItemsAreScheduled()
        {
            MockedAtModule module;

            DateTime[] events;
            DateTime   now;

            module = new MockedAtModule();
            Assert.AreEqual(true, module.Start());

            now    = DateTime.Now;
            events = new DateTime[] { now.AddHours(1) };
            foreach (DateTime ev in events)
            {
                module.Add(ev, ev);
            }
            Thread.Sleep(1000);
            Assert.AreEqual(true, module.Stop());
        }