Example #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();
        }
        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();
        }
Example #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();
        }
        public async void EnableAutoRetry()
        {
            using (var rc = new RestClient(
                       Environment.GetEnvironmentVariable("RINGCENTRAL_CLIENT_ID"),
                       Environment.GetEnvironmentVariable("RINGCENTRAL_CLIENT_SECRET"),
                       Environment.GetEnvironmentVariable("RINGCENTRAL_SERVER_URL")
                       ))
            {
                await rc.Authorize(
                    Environment.GetEnvironmentVariable("RINGCENTRAL_USERNAME"),
                    Environment.GetEnvironmentVariable("RINGCENTRAL_EXTENSION"),
                    Environment.GetEnvironmentVariable("RINGCENTRAL_PASSWORD")
                    );

                var retryExtension = new RetryExtension();
                rc.InstallExtension(retryExtension);
                retryExtension.enabled = false; // remove this line to enable auto retry
                var extInfo = await rc.Restapi().Account().Extension().Get();

                Assert.NotNull(extInfo);
                Assert.NotNull(extInfo.id);
            }
        }
        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();
        }