/// <summary>
        /// Initializes a new instance of the <see cref="MessageBusConfiguration"/> class.
        /// </summary>
        /// <param name="serviceProvider">The configured <see cref="IServiceProvider">service provider</see>.</param>
        /// <param name="clock">The configured <see cref="IClock">clock</see>.</param>
        /// <param name="persistence">The <see cref="IMapPersistence">mapping for persistence</see>.</param>
        /// <param name="messageSender">The configured <see cref="IMessageSender">message sender</see>.</param>
        /// <param name="messageReceiver">The configured <see cref="IMessageReceiver">message receiver</see>.</param>
        /// <param name="commandHandlerRegistrar">The configured <see cref="ICommandHandlerRegistrar">command handler registrar</see>.</param>
        /// <param name="eventReceiverRegistrar">The configured <see cref="IEventReceiverRegistrar">event handler registrar</see>.</param>
        /// <param name="sagaConfiguration">The <see cref="SagaConfiguration">saga configuration</see> used by the message bus.</param>
        /// <param name="uniqueIdGenerator">The configured <see cref="IUniqueIdGenerator">unique identifier generator</see> used by the message bus.</param>
        public MessageBusConfiguration(
            IServiceProvider serviceProvider,
            IClock clock,
            IMapPersistence persistence,
            IMessageSender messageSender,
            IMessageReceiver messageReceiver,
            ICommandHandlerRegistrar commandHandlerRegistrar,
            IEventReceiverRegistrar eventReceiverRegistrar,
            SagaConfiguration sagaConfiguration,
            IUniqueIdGenerator uniqueIdGenerator)
        {
            Arg.NotNull(serviceProvider, nameof(serviceProvider));
            Arg.NotNull(clock, nameof(clock));
            Arg.NotNull(persistence, nameof(persistence));
            Arg.NotNull(messageSender, nameof(messageSender));
            Arg.NotNull(messageReceiver, nameof(messageReceiver));
            Arg.NotNull(commandHandlerRegistrar, nameof(commandHandlerRegistrar));
            Arg.NotNull(eventReceiverRegistrar, nameof(eventReceiverRegistrar));
            Arg.NotNull(sagaConfiguration, nameof(sagaConfiguration));
            Arg.NotNull(uniqueIdGenerator, nameof(uniqueIdGenerator));

            this.serviceProvider = serviceProvider;
            Clock             = clock;
            Persistence       = persistence;
            MessageSender     = messageSender;
            MessageReceiver   = messageReceiver;
            CommandHandlers   = commandHandlerRegistrar;
            EventReceivers    = eventReceiverRegistrar;
            Sagas             = sagaConfiguration;
            UniqueIdGenerator = uniqueIdGenerator;
        }
        /// <summary>
        /// Indicates the message bus configuration will have the specified persistence mapping.
        /// </summary>
        /// <param name="value">The configured <see cref="IMapPersistence">persistence mapping</see>.</param>
        /// <returns>The original <see cref="MessageBusConfigurationBuilder"/> instance.</returns>
        public virtual MessageBusConfigurationBuilder MapPersistenceWith(IMapPersistence value)
        {
            Arg.NotNull(value, nameof(value));
            Contract.Ensures(Contract.Result <MessageBusConfiguration>() != null);

            Persistence = value;
            return(this);
        }
        void SaveLoadTest(IMapPersistence persister)
        {
            var tmpPath = Path.GetTempPath() + Guid.NewGuid();

            Directory.CreateDirectory(tmpPath);
            var tmpMap = tmpPath + "/temp.map";
            var map    = Map.New(new MapSettings(), device.Device9);

            persister.Save(map, tmpMap);
            persister.Load(tmpMap, device.Device9);
            Directory.Delete(tmpPath, true);
        }