示例#1
0
        public void ChangeTimedTriggerWithRunningModule()
        {
            TimedTriggerExtension extension = new TimedTriggerExtension();

            extension.ModuleController = m_moduleController;
            extension.Attach();

            m_moduleController.RaiseAfterModuleStartEvent();
            Assert.AreEqual(0, m_moduleController.EnquedMessages.Count);
            Thread.Sleep(100);
            Assert.AreEqual(0, m_moduleController.EnquedMessages.Count);
            extension.ChangeTimer(500, 1000);
            Thread.Sleep(750);
            Assert.AreEqual(1, m_moduleController.EnquedMessages.Count);
            Assert.IsInstanceOfType(typeof(TimedTriggerMessage), m_moduleController.EnquedMessages[0]);
            Thread.Sleep(1000);
            Assert.AreEqual(2, m_moduleController.EnquedMessages.Count);
            Assert.IsInstanceOfType(typeof(TimedTriggerMessage), m_moduleController.EnquedMessages[1]);
            extension.ChangeTimer(500, 500);
            Thread.Sleep(750);
            Assert.AreEqual(3, m_moduleController.EnquedMessages.Count);
            Assert.IsInstanceOfType(typeof(TimedTriggerMessage), m_moduleController.EnquedMessages[2]);
            extension.ChangeTimer(Timeout.Infinite, Timeout.Infinite);
            Thread.Sleep(750);
            Assert.AreEqual(3, m_moduleController.EnquedMessages.Count);

            extension.Detach();
        }
示例#2
0
        public void RescheduleTriggerOnRestart()
        {
            TimedTriggerExtension extension = new TimedTriggerExtension(200, 100, false);

            extension.ModuleController = m_moduleController;
            extension.Attach();

            m_moduleController.RaiseAfterModuleStartEvent();
            Assert.AreEqual(0, m_moduleController.EnquedMessages.Count);
            Thread.Sleep(100);
            m_moduleController.RaiseBeforeModuleStopEvent();
            m_moduleController.RaiseAfterModuleStartEvent();
            Thread.Sleep(150);
            Assert.AreEqual(1, m_moduleController.EnquedMessages.Count);
            Assert.IsInstanceOfType(typeof(TimedTriggerMessage), m_moduleController.EnquedMessages[0]);
            Thread.Sleep(100);
            Assert.AreEqual(2, m_moduleController.EnquedMessages.Count);
            Assert.IsInstanceOfType(typeof(TimedTriggerMessage), m_moduleController.EnquedMessages[1]);
            m_moduleController.RaiseBeforeModuleStopEvent();
            m_moduleController.RaiseAfterModuleStartEvent();
            Thread.Sleep(100);
            Assert.AreEqual(3, m_moduleController.EnquedMessages.Count);
            Assert.IsInstanceOfType(typeof(TimedTriggerMessage), m_moduleController.EnquedMessages[2]);

            extension.Detach();
        }
        public void PreConfiguredTimedTrigger()
        {
            TimedTriggerExtension extension = new TimedTriggerExtension(500, 1000, true);
            extension.ModuleController = m_moduleController;
            extension.Attach();

            m_moduleController.RaiseAfterModuleStartEvent();
            Assert.AreEqual(0, m_moduleController.EnquedMessages.Count);
            Thread.Sleep(750);
            Assert.AreEqual(1, m_moduleController.EnquedMessages.Count);
            Assert.IsInstanceOfType(typeof(TimedTriggerMessage), m_moduleController.EnquedMessages[0]);
            Thread.Sleep(1000);
            Assert.AreEqual(2, m_moduleController.EnquedMessages.Count);
            Assert.IsInstanceOfType(typeof(TimedTriggerMessage), m_moduleController.EnquedMessages[1]);
            Thread.Sleep(1000);
            Assert.AreEqual(3, m_moduleController.EnquedMessages.Count);
            Assert.IsInstanceOfType(typeof(TimedTriggerMessage), m_moduleController.EnquedMessages[2]);
            m_moduleController.RaiseBeforeModuleStopEvent();
            Thread.Sleep(1000);
            Assert.AreEqual(3, m_moduleController.EnquedMessages.Count);
            
            extension.Detach();
        }
        public void ChangeTimedTriggerWithRunningModule()
        {
            TimedTriggerExtension extension = new TimedTriggerExtension();
            extension.ModuleController = m_moduleController;
            extension.Attach();

            m_moduleController.RaiseAfterModuleStartEvent();
            Assert.AreEqual(0, m_moduleController.EnquedMessages.Count);
            Thread.Sleep(100);
            Assert.AreEqual(0, m_moduleController.EnquedMessages.Count);
            extension.ChangeTimer(500, 1000);
            Thread.Sleep(750);
            Assert.AreEqual(1, m_moduleController.EnquedMessages.Count);
            Assert.IsInstanceOfType(typeof(TimedTriggerMessage), m_moduleController.EnquedMessages[0]);
            Thread.Sleep(1000);
            Assert.AreEqual(2, m_moduleController.EnquedMessages.Count);
            Assert.IsInstanceOfType(typeof(TimedTriggerMessage), m_moduleController.EnquedMessages[1]);
            extension.ChangeTimer(500, 500);
            Thread.Sleep(750);
            Assert.AreEqual(3, m_moduleController.EnquedMessages.Count);
            Assert.IsInstanceOfType(typeof(TimedTriggerMessage), m_moduleController.EnquedMessages[2]);
            extension.ChangeTimer(Timeout.Infinite, Timeout.Infinite);
            Thread.Sleep(750);
            Assert.AreEqual(3, m_moduleController.EnquedMessages.Count);

            extension.Detach();
        }