public ExcessReads()
            {
                _q = _world.NewJobQueue(configuration: _configuration);

                _excess = _world.NewJob;


                _world.PersistenceStore.LoadSuspended(typeof(string), 0).ReturnsForAnyArgs(new[] { _excess });

                _q.Write(_world.NewJob);
                _q.Write(_excess);
            }
        public QueueConfiguration Create()
        {
            var readyItems = _persistenceStore.LoadBy(JobStatus.Ready).ToArray();
            var cancellingItems = _persistenceStore.LoadBy(JobStatus.Cancelling).ToArray();

            var runningItems = _persistenceStore.LoadBy(JobStatus.Running).ToArray();
            var failedItems = _persistenceStore.LoadBy(JobStatus.Failed).ToArray();
            var waitingForChildren = _persistenceStore.LoadBy(JobStatus.WaitingForChildren).ToArray();

            //Exclude job root while picking the runnable items
            var cancellationInitiatedItems = _persistenceStore.LoadBy(JobStatus.CancellationInitiated)
                                                              .Where(_=>_.ParentId != null);

            var partiallyCompletedItems =  _persistenceStore.LoadBy(JobStatus.ReadyToComplete)
                                                            .Concat(_persistenceStore.LoadBy(JobStatus.ReadyToPoison))
                                                            .Concat(cancellationInitiatedItems)
                                                            .ToArray();

            var all = partiallyCompletedItems.Concat(readyItems)
                                             .Concat(cancellingItems)
                                             .Concat(failedItems)
                                             .Concat(waitingForChildren)
                                             .Concat(runningItems)
                                             .ToArray();

            var totalSuspendedItemsInSpecificQueues = 0;
            var activitySpecificQueues = new Dictionary<Type, IJobQueue>();

            foreach (var activityConfiguration in _configuration.ActivityConfiguration)
            {
                var suspendedCount = _persistenceStore.CountSuspended(activityConfiguration.Type);
                var filtered = Filter(all, activityConfiguration.Type);
                all = filtered.Item2;
                totalSuspendedItemsInSpecificQueues += suspendedCount;

                activitySpecificQueues[activityConfiguration.Type] =
                    new JobQueue(filtered.Item1, suspendedCount, activityConfiguration,
                        _configuration.ActivityConfiguration, _persistenceStore, _eventStream, _recoverableAction, _jobMutator);

                PublishQueueInitializedEvent(filtered.Item1.Length, suspendedCount, activityConfiguration.Type);
            }

            var suspendedCountForDefaultQueue = _persistenceStore.CountSuspended(null) -
                                                totalSuspendedItemsInSpecificQueues;

            var defaultQueue = new JobQueue(all, suspendedCountForDefaultQueue,
                _configuration.DefaultActivityConfiguration, _configuration.ActivityConfiguration, _persistenceStore,
                _eventStream, _recoverableAction, _jobMutator);

            PublishQueueInitializedEvent(all.Length, suspendedCountForDefaultQueue);

            return new QueueConfiguration(defaultQueue, activitySpecificQueues);
        }
 public ExcessWrites()
 {
     _excessItem = _world.NewJob;
     _queue = _world.NewJobQueue(configuration: _configuration);
     _queue.Write(_world.NewJob);
 }