public void Queue_Processing_CorruptedEvent()
        {
            // Enqueue events for further handling
            bus.Subscribe(testService.Enque <TestEvent>());

            // except test to throw Exception event
            Exception exception = null;

            bus.Subscribe <Exception>(e =>
                                      exception = e);

            int counter          = 0;
            int backofIntervalMs = 50;
            // Subscribe handler which waits 50 ms
            Delegate <TestEvent> handler = (e) => { counter++; throw new NotImplementedException(); };

            bus.Subscribe(handler.WhenQueued().RetryQueued(3,
                                                           Backoff.Fixed(TimeSpan.FromMilliseconds(backofIntervalMs))
                                                           ));

            bus.Publish(new TestEvent(), this);

            // There is event to handle
            Assert.AreEqual(1, repository.Queue.Where(e => e.DeclaringEventType == typeof(TestEvent).AssemblyQualifiedName).Count());

            testService.ProcessEvents();

            Assert.AreEqual(0, repository.Queue.Where(e => e.DeclaringEventType == typeof(TestEvent).ToString()).Count());
            Assert.IsNotNull(exception);
            Assert.IsInstanceOfType(exception, typeof(FormatException));
        }
        public void Queue_Processing_WithOnFail()
        {
            // Enqueue events for further handling
            bus.Subscribe(testService.Enque <TestEvent>());

            int counter          = 0;
            int backofIntervalMs = 50;
            // Subscribe handler which waits 50 ms
            Delegate <TestEvent> handler = (e) => { counter++; throw new NotImplementedException(); };

            bus.Subscribe(handler.WhenQueued().RetryQueued(3,
                                                           Backoff.Fixed(TimeSpan.FromMilliseconds(backofIntervalMs))
                                                           ));

            bus.Publish(new TestEvent(), this);

            DateTime start = DateTime.Now;

            while (counter <= 3)
            {
                testService.ProcessEvents();
            }
            Assert.IsTrue(DateTime.Now.Subtract(start).TotalMilliseconds > 3 * backofIntervalMs);
        }