Exemplo n.º 1
0
        public void SetUp()
        {
            _consumerRepository = new ConsumerRepository <TestEvent>();
            _eventProcessor1    = new DummyEventProcessor();
            _eventProcessor2    = new DummyEventProcessor();

            _handler1 = new SleepingEventHandler();
            _handler2 = new SleepingEventHandler();

            _barrier1 = new DummySequenceBarrier();
            _barrier2 = new DummySequenceBarrier();
        }
Exemplo n.º 2
0
        public void ShouldCreateEventProcessorGroupForFirstEventProcessors()
        {
            _executor.IgnoreExecutions();
            IEventHandler <TestEvent> eventHandler1 = new SleepingEventHandler();
            IEventHandler <TestEvent> eventHandler2 = new SleepingEventHandler();

            var eventHandlerGroup =
                _disruptor.HandleEventsWith(eventHandler1, eventHandler2);

            _disruptor.Start();

            Assert.IsNotNull(eventHandlerGroup);
            Assert.That(_executor.GetExecutionCount(), Is.EqualTo(2));
        }
Exemplo n.º 3
0
        public void ShouldCreateEventProcessorGroupForFirstEventProcessors()
        {
            _taskScheduler.IgnoreExecutions();
            var eventHandler1 = new SleepingEventHandler();
            var eventHandler2 = new SleepingEventHandler();

            var eventHandlerGroup =
                _disruptor.HandleEventsWith(eventHandler1, eventHandler2);

            _disruptor.Start();

            Assert.IsNotNull(eventHandlerGroup);
            Assert.That(_taskScheduler.TaskCount, Is.EqualTo(2));
        }
Exemplo n.º 4
0
        public async Task ShouldCreateEventProcessorGroupForFirstEventProcessorsAsync()
        {
            _executor.IgnoreExecutions();

            var eventHandler1 = new SleepingEventHandler();
            var eventHandler2 = new SleepingEventHandler();

            var eventHandlerGroup = _disruptor.HandleEventsWith(eventHandler1, eventHandler2);

            await _disruptor.StartAsync();

            Assert.NotNull(eventHandlerGroup);
            Assert.Equal(2, _executor.ExecutionCount);
        }
        public ConsumerRepositoryTest()
        {
            _repository = new ConsumerRepository <TestEvent>();
            _processor1 = new DummyEventProcessor();
            _processor2 = new DummyEventProcessor();

            _processor1.Run();
            _processor2.Run();

            _handler1 = new SleepingEventHandler();
            _handler2 = new SleepingEventHandler();

            _barrier1 = new DummySequenceBarrier();
            _barrier2 = new DummySequenceBarrier();
        }
Exemplo n.º 6
0
        public void ShouldSetSequenceForHandlerIfAddedAfterPublish()
        {
            var rb = _disruptor.RingBuffer;
            var b1 = new SleepingEventHandler();
            var b2 = new SleepingEventHandler();
            var b3 = new SleepingEventHandler();

            rb.Publish(rb.Next());
            rb.Publish(rb.Next());
            rb.Publish(rb.Next());
            rb.Publish(rb.Next());
            rb.Publish(rb.Next());
            rb.Publish(rb.Next());

            _disruptor.HandleEventsWith(b1, b2, b3);

            Assert.That(_disruptor.GetSequenceValueFor(b1), Is.EqualTo(5L));
            Assert.That(_disruptor.GetSequenceValueFor(b2), Is.EqualTo(5L));
            Assert.That(_disruptor.GetSequenceValueFor(b3), Is.EqualTo(5L));
        }
Exemplo n.º 7
0
        public void SetUp()
        {
            _consumerRepository = new ConsumerRepository <TestEvent>();
            _eventProcessor1    = new Mock <IEventProcessor>();
            _eventProcessor2    = new Mock <IEventProcessor>();

            var sequence1 = new Sequence();
            var sequence2 = new Sequence();

            _eventProcessor1.Setup(x => x.Sequence).Returns(sequence1);
            _eventProcessor1.Setup(x => x.IsRunning).Returns(true);
            _eventProcessor2.Setup(x => x.Sequence).Returns(sequence2);
            _eventProcessor2.Setup(x => x.IsRunning).Returns(true);

            _handler1 = new SleepingEventHandler();
            _handler2 = new SleepingEventHandler();

            _barrier1 = new Mock <ISequenceBarrier>();
            _barrier2 = new Mock <ISequenceBarrier>();
        }
        public void SetUp()
        {
            _consumerRepository = new ConsumerRepository<TestEvent>();
            _eventProcessor1 = new Mock<IEventProcessor>();
            _eventProcessor2 = new Mock<IEventProcessor>();

            var sequence1 = new Sequence();
            var sequence2 = new Sequence();

            _eventProcessor1.Setup(x => x.Sequence).Returns(sequence1);
            _eventProcessor1.Setup(x => x.IsRunning).Returns(true);
            _eventProcessor2.Setup(x => x.Sequence).Returns(sequence2);
            _eventProcessor2.Setup(x => x.IsRunning).Returns(true);

            _handler1 = new SleepingEventHandler();
            _handler2 = new SleepingEventHandler();

            _barrier1 = new Mock<ISequenceBarrier>();
            _barrier2 = new Mock<ISequenceBarrier>();
        }
Exemplo n.º 9
0
        public void ShouldSetSequenceForHandlerIfAddedAfterPublish()
        {
            var rb = _disruptor.GetRingBuffer();

            var h1 = new SleepingEventHandler();
            var h2 = new SleepingEventHandler();
            var h3 = new SleepingEventHandler();

            rb.Publish(rb.Next());
            rb.Publish(rb.Next());
            rb.Publish(rb.Next());
            rb.Publish(rb.Next());
            rb.Publish(rb.Next());
            rb.Publish(rb.Next());

            _disruptor.HandleEventsWith(h1, h2, h3);

            Assert.Equal(5L, _disruptor.GetSequenceValueFor(h1));
            Assert.Equal(5L, _disruptor.GetSequenceValueFor(h2));
            Assert.Equal(5L, _disruptor.GetSequenceValueFor(h3));
        }
        public void SetUp()
        {
            consumerRepository = new ConsumerRepository <TestEvent>();

            eventProcessorMock1 = new Mock <IEventProcessor>();
            eventProcessorMock2 = new Mock <IEventProcessor>();

            //eventProcessorMock1.Verify(e => e.IsRunning(), "IEventProcessor not Running ");
            //eventProcessorMock2.Verify(e => e.IsRunning(), "IEventProcessor not Running ");

            var sequence1 = new Sequence();
            var sequence2 = new Sequence();

            handler1 = new SleepingEventHandler();
            handler2 = new SleepingEventHandler();

            eventProcessorMock1.SetupGet(e => e.Sequence).Returns(sequence1);
            eventProcessorMock2.SetupGet(e => e.Sequence).Returns(sequence2);

            barrier1 = new Mock <ISequenceBarrier>();
            barrier2 = new Mock <ISequenceBarrier>();
        }
        public void SetUp()
        {
            consumerRepository = new ConsumerRepository<TestEvent>();

            eventProcessorMock1 = new Mock<IEventProcessor>();
            eventProcessorMock2 = new Mock<IEventProcessor>();

            //eventProcessorMock1.Verify(e => e.IsRunning(), "IEventProcessor not Running ");
            //eventProcessorMock2.Verify(e => e.IsRunning(), "IEventProcessor not Running ");

            var sequence1 = new Sequence();
            var sequence2 = new Sequence();

            handler1 = new SleepingEventHandler();
            handler2 = new SleepingEventHandler();

            eventProcessorMock1.SetupGet(e => e.Sequence).Returns(sequence1);
            eventProcessorMock2.SetupGet(e => e.Sequence).Returns(sequence2);

            barrier1 = new Mock<ISequenceBarrier>();
            barrier2 = new Mock<ISequenceBarrier>();
          
        }