public void SecondServiceLocatorResolves()
        {
            var bus = new Bus();

            #region composition root

            var catalog = new AggregateCatalog();
            catalog.Catalogs.Add(new AssemblyCatalog(typeof(Message2Consumer).GetTypeInfo().Assembly));
            var compositionContainer = new CompositionContainer(catalog);
            var message2Consumer     = new Message2Consumer();
            ServiceLocator.SetLocatorProvider(() => new MefServiceLocator(compositionContainer));

            #endregion

            bus.SetServiceLocator(new MefServiceLocator(compositionContainer));
            compositionContainer.ComposeExportedValue(message2Consumer);
#if SUPPORT_ASYNC_CONSUMER
            var message3AsyncConsumer = new Message3AsyncConsumer();
            compositionContainer.ComposeExportedValue(message3AsyncConsumer);
#endif
            compositionContainer.ComposeExportedValue(new Pipe());
            compositionContainer.ComposeExportedValue(new Pipe23());
            bus.SetServiceLocator(new MefServiceLocator(compositionContainer));

            var directory = Path.GetDirectoryName(new Uri(GetType().GetTypeInfo().Assembly.CodeBase).LocalPath);
            bus.AddHandlersAndTranslators(directory, "Tests*.dll", "Tests.Mocks");

            bus.Handle(new Message2());

            Assert.Equal(1, message2Consumer.MessageReceivedCount);
        }
        public void NullBusThrowsWhenSettingServiceLocator()
        {
            Bus bus = null;

            // ReSharper disable once ExpressionIsAlwaysNull
            Assert.Throws <ArgumentNullException>(() => bus.SetServiceLocator(null));
        }
        public void NullServiceLocatorThrowsWhenSettingServiceLocator()
        {
            Bus bus = new Bus();

            Assert.Throws <ArgumentNullException>(() => bus.SetServiceLocator(null));
        }