コード例 #1
0
        public void Retry()
        {
            ArgumentException exception = new ArgumentException("TestException");
            RetryExtension    extension = new RetryExtension("Scheduler", 1000, 2, typeof(Exception));

            extension.ModuleController  = m_moduleController;
            extension.ModuleCoordinator = m_moduleCoordinator;
            extension.RetryExceptionTypes.Add(typeof(ArgumentException));
            extension.Attach();

            Expect.Exactly(2).On(m_moduleCoordinator).Method("PostMessage").With(
                new EqualMatcher("Scheduler"),
                new ScheduledMessageMatcher("TestModule", "TestMessage"));

            bool exceptionHandled;

            m_moduleController.RaiseConsumeMessageExceptionOccurred("TestModule",
                                                                    "TestMessage", exception, out exceptionHandled);
            Assert.IsTrue(exceptionHandled);

            m_moduleController.RaiseConsumeMessageExceptionOccurred("TestModule",
                                                                    "TestMessage", exception, out exceptionHandled);
            Assert.IsTrue(exceptionHandled);

            m_moduleController.RaiseConsumeMessageExceptionOccurred("TestModule",
                                                                    "TestMessage", exception, out exceptionHandled);
            Assert.IsFalse(exceptionHandled);

            extension.Detach();

            m_mockery.VerifyAllExpectationsHaveBeenMet();
        }
コード例 #2
0
        public void Retry()
        {
            ArgumentException exception = new ArgumentException("TestException");
            RetryExtension extension = new RetryExtension("Scheduler", 1000, 2, typeof(Exception));
            extension.ModuleController = m_moduleController;
            extension.ModuleCoordinator = m_moduleCoordinator;
            extension.RetryExceptionTypes.Add(typeof(ArgumentException));
            extension.Attach();

            Expect.Exactly(2).On(m_moduleCoordinator).Method("PostMessage").With(
                new EqualMatcher("Scheduler"),
                new ScheduledMessageMatcher("TestModule", "TestMessage"));

            bool exceptionHandled;
            m_moduleController.RaiseConsumeMessageExceptionOccurred("TestModule",
                "TestMessage", exception, out exceptionHandled);
            Assert.IsTrue(exceptionHandled);

            m_moduleController.RaiseConsumeMessageExceptionOccurred("TestModule",
                "TestMessage", exception, out exceptionHandled);
            Assert.IsTrue(exceptionHandled);

            m_moduleController.RaiseConsumeMessageExceptionOccurred("TestModule",
                "TestMessage", exception, out exceptionHandled);
            Assert.IsFalse(exceptionHandled);

            extension.Detach();

            m_mockery.VerifyAllExpectationsHaveBeenMet();
        }
コード例 #3
0
        public void NotSupportedException()
        {
            ArgumentException exception = new ArgumentException("TestException");
            RetryExtension    extension = new RetryExtension("Scheduler", 1000, 2, typeof(NotImplementedException));

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

            Expect.Never.On(m_moduleCoordinator).Method("PostMessage");

            bool exceptionHandled;

            m_moduleController.RaiseConsumeMessageExceptionOccurred("TestModule",
                                                                    "TestMessage", exception, out exceptionHandled);
            Assert.IsFalse(exceptionHandled);

            extension.Detach();

            m_mockery.VerifyAllExpectationsHaveBeenMet();
        }
コード例 #4
0
        public void NotSupportedException()
        {
            ArgumentException exception = new ArgumentException("TestException");
            RetryExtension extension = new RetryExtension("Scheduler", 1000, 2, typeof(NotImplementedException));
            extension.ModuleController = m_moduleController;
            extension.ModuleCoordinator = m_moduleCoordinator;
            extension.Attach();

            Expect.Never.On(m_moduleCoordinator).Method("PostMessage");

            bool exceptionHandled;
            m_moduleController.RaiseConsumeMessageExceptionOccurred("TestModule",
                "TestMessage", exception, out exceptionHandled);
            Assert.IsFalse(exceptionHandled);

            extension.Detach();

            m_mockery.VerifyAllExpectationsHaveBeenMet();
        }