public void TestExchangeService_BindExchanges_NonExistingExchanges()
        {
            // These exchanges do not exist
            ExchangeBindingModel ex = new ExchangeBindingModel()
            {
                Source      = "Test.Exchange3",
                Destination = "Test.Exchange4"
            };

            Assert.That(() =>
            {
                BaseExchangeService.Bind(ex);
            }, Throws.TypeOf <ServiceException>());
        }
        public void TestExchangeService_UnbindExchanges()
        {
            // Create exchanges
            TestExchangeService_DeclareExchange_AddressObject();
            TestExchangeService_DeclareExchange_StringParams();

            // At this stage, 2 exchanges have been created - 'Test.Exchange' & 'Test.Exchange2'

            ExchangeBindingModel ex = new ExchangeBindingModel()
            {
                Source      = "Test.Exchange2",
                Destination = "Test.Exchange"
            };

            Assert.DoesNotThrow(() => { BaseExchangeService.Unbind(ex); });
        }
Пример #3
0
 /// <summary>
 /// Unbinds a single exchange from another exchange
 /// </summary>
 /// <param name="binding"></param>
 /// <exception cref="ArgumentNullException"></exception>
 /// <exception cref="ServiceException"></exception>
 /// <exception cref="ValidationException"></exception>
 public void Unbind(ExchangeBindingModel binding)
 {
     try
     {
         Validate(binding, "Exchange to unbind cannot be null");
         Channel.ExchangeUnbind(binding.Destination, binding.Source, binding.RoutingKey, binding.Arguments);
     }
     catch (Exception ex) when(ex is ArgumentNullException || ex is ServiceException || ex is ValidationException)
     {
         throw;
     }
     catch (OperationInterruptedException ex)
     {
         Logger.Warn(ex.Message);
         throw new ServiceException("Exchange Service Exception: One or more exchanges do not exist is the likely cause, please see log for more details.");
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message);
         throw new ServiceException("Exchange Service Exception: please see log for more details.");
     }
 }