Dispatches messages directly to subscribers
This delivery core can be useful if you do not require queued delivery or are dispatching to endpoints that manage their own queues.
Inheritance: DeliveryCore
        public void Action_Stops_On_Stop()
        {
            long count = 0;

            TimerRuntimeService timerService = new TimerRuntimeService();
            timerService.AddEvent(new TimerEvent(() => { Interlocked.Increment(ref count); }, TimeSpan.FromMilliseconds(1000)));

            DeliveryCore deliveryCore = new DirectDeliveryCore();

            using (ServiceBusRuntime runtime = new ServiceBusRuntime(deliveryCore, timerService))
            {
                runtime.Start();

                Thread.Sleep(1100);

                long beforeStopCount = Interlocked.Read(ref count);

                runtime.Stop();

                Assert.GreaterOrEqual(beforeStopCount, 0);

                Thread.Sleep(1100);

                long afterStopCount = Interlocked.Read(ref count);

                Assert.GreaterOrEqual(beforeStopCount, afterStopCount);
            }
        }
        public void Action_Ticks_On_Intervals()
        {
            long count = 0;

            TimerRuntimeService timerService = new TimerRuntimeService();
            timerService.AddEvent(new TimerEvent(() => { Interlocked.Increment(ref count); }, TimeSpan.FromMilliseconds(1000)));

            DeliveryCore deliveryCore = new DirectDeliveryCore();

            using (ServiceBusRuntime runtime = new ServiceBusRuntime(deliveryCore, timerService))
            {
                runtime.Start();

                Thread.Sleep(9100);

                long curCount = Interlocked.Read(ref count);

                runtime.Stop();

                Assert.AreEqual(9, curCount);
            }
        }
        public void Event_Starts_At_Preset_Time()
        {
            long count = 0;

            TimerRuntimeService timerService = new TimerRuntimeService();
            timerService.AddEvent(new TimerEvent(() => { Interlocked.Increment(ref count); }, TimeSpan.FromMilliseconds(100), DateTime.Now.AddSeconds(5)));

            DeliveryCore deliveryCore = new DirectDeliveryCore();

            using (ServiceBusRuntime runtime = new ServiceBusRuntime(deliveryCore, timerService))
            {
                runtime.Start();

                Thread.Sleep(3000);

                long curCount = Interlocked.Read(ref count);
                Assert.AreEqual(0, curCount);

                Thread.Sleep(3000);

                curCount = Interlocked.Read(ref count);

                runtime.Stop();

                Assert.GreaterOrEqual(curCount, 0);
            }
        }
        public void Event_Auto_Starts_When_Running()
        {
            long count = 0;

            TimerRuntimeService timerService = new TimerRuntimeService();
            var evt = new TimerEvent(() => { Interlocked.Increment(ref count); }, TimeSpan.FromMilliseconds(100));

            DeliveryCore deliveryCore = new DirectDeliveryCore();

            using (ServiceBusRuntime runtime = new ServiceBusRuntime(deliveryCore, timerService))
            {
                runtime.Start();

                Thread.Sleep(500);

                long curCount = Interlocked.Read(ref count);
                Assert.AreEqual(0, curCount);

                timerService.AddEvent(evt);

                Thread.Sleep(500);

                curCount = Interlocked.Read(ref count);

                runtime.Stop();

                Assert.GreaterOrEqual(curCount, 3);
            }
        }