protected override void BeforeBuildingHandler()
        {
            base.BeforeBuildingHandler();

            _storageMock = new Mock <IStorage>();
            var persistenceConfigurationMock = new Mock <IPersistenceConfiguration>();

            persistenceConfigurationMock.SetupGet(conf => conf.PersisterBatchSize).Returns(() => 100);

            _inMemoryMessageMatcher = new InMemoryMessageMatcher(persistenceConfigurationMock.Object, _storageMock.Object, Bus);
            _inMemoryMessageMatcher.Start();
            MockContainer.Register <IInMemoryMessageMatcher>(_inMemoryMessageMatcher);
        }
        public void should_batch()
        {
            using (SystemDateTime.PauseTime())
            {
                var persistedBatches = new List <List <MatcherEntry> >();
                CapturePersistedBatches(persistedBatches);
                _batchSize = 5;

                for (var i = 0; i < 25; ++i)
                {
                    EnqueueMessageToPersist();
                }

                _matcher.Start();
                EnqueueMessageToPersist();
                _matcher.Stop();

                persistedBatches.Count.ShouldEqual(6);
                persistedBatches.Count(batch => batch.Count == 5).ShouldEqual(5);
                persistedBatches.Count(batch => batch.Count == 1).ShouldEqual(1);
            }
        }