public void TestExchangeService_DeleteExchange_DeleteObject() { // Create data ExchangeDeleteModel exd = new ExchangeDeleteModel() { Name = "mycompany.fanout.exchange", IfUnused = false // override, remove the exchange regardless if it is in use or not }; // Assert Assert.DoesNotThrow(() => { BaseExchangeService.Delete(exd); }); // Remove a second one exd.Name = "company.direct.exchange"; Assert.DoesNotThrow(() => { BaseExchangeService.Delete(exd); }); }
public void TestExchangeService_DeleteMany() { var ex = new ExchangeDeleteModel() { Name = "Test.Exchange.ToDelete" }; var ex2 = new ExchangeDeleteModel() { Name = "Test.Exchange.ToDelete2" }; List <ExchangeDeleteModel> exchanges = new List <ExchangeDeleteModel>() { ex, ex2 }; // Assert Assert.DoesNotThrow(() => { BaseExchangeService.DeleteMany(exchanges); }); }
/// <summary> /// Deletes a single exchange /// </summary> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="ServiceException"></exception> /// <exception cref="ValidationException"></exception> /// <param name="exchange"></param> public void Delete(ExchangeDeleteModel exchange) { try { Validate(exchange, "Exchange to delete cannot be null"); Channel.ExchangeDelete(exchange.Name, exchange.IfUnused); } 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: Exchange still in use 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."); } }