/// <summary>The apply.</summary> /// <returns>The System.Boolean.</returns> public bool Apply() { // Check at the beginning, so this can be used as a static field if (this.assumeOnline) { Assume.That(BrokerOnline.Get(this.port)); } else { Assume.That(BrokerOffline.Get(this.port)); } var connectionFactory = new CachingConnectionFactory(); try { connectionFactory.Port = this.port; if (!string.IsNullOrWhiteSpace(this.hostName)) { connectionFactory.Host = this.hostName; } var admin = new RabbitAdmin(connectionFactory); var exchange = new FederatedExchange("fedDirectRuleTest"); exchange.BackingType = "direct"; exchange.UpstreamSet = "upstream-set"; admin.DeclareExchange(exchange); admin.DeleteExchange("fedDirectRuleTest"); BrokerOffline.AddOrUpdate(this.port, false); if (!this.assumeOnline) { Assume.That(BrokerOffline.Get(this.port)); } } catch (Exception e) { Logger.Warn(m => m("Not executing tests because federated connectivity test failed"), e); BrokerOnline.AddOrUpdate(this.port, false); if (this.assumeOnline) { Assume.That(e == null, "An exception occurred."); return false; } } finally { connectionFactory.Dispose(); } return true; // return super.apply(base, method, target); }