public async Task Should_create_exchange_to_exchange_binding() { const string sourceExchangeName = "management_api_test_source_exchange"; const string destinationExchangeName = "management_api_test_destination_exchange"; var vhost = await managementClient.GetVhostAsync(vhostName).ConfigureAwait(false); var sourceExchangeInfo = new ExchangeInfo(sourceExchangeName, "direct"); var destinationExchangeInfo = new ExchangeInfo(destinationExchangeName, "direct"); var sourceExchange = await managementClient.CreateExchangeAsync(sourceExchangeInfo, vhost).ConfigureAwait(false); var destinationExchange = await managementClient.CreateExchangeAsync(destinationExchangeInfo, vhost) .ConfigureAwait(false); await managementClient.CreateBindingAsync(sourceExchange, destinationExchange, new BindingInfo("#")) .ConfigureAwait(false); var binding = (await managementClient.GetBindingsWithSourceAsync(sourceExchange).ConfigureAwait(false)) .First(); await managementClient.DeleteExchangeAsync(sourceExchange).ConfigureAwait(false); await managementClient.DeleteExchangeAsync(destinationExchange).ConfigureAwait(false); Assert.Equal("exchange", binding.DestinationType); Assert.Equal(destinationExchangeName, binding.Destination); Assert.Equal("#", binding.RoutingKey); }
public async Task Should_get_all_bindings_for_which_the_exchange_is_the_source() { var sourceXchange = await CreateExchange("sourceXcg").ConfigureAwait(false); var destionationXchange = await CreateExchange("destinationXcg").ConfigureAwait(false); var bindingInfo = new BindingInfo("#"); await managementClient.CreateBindingAsync(sourceXchange, destionationXchange, bindingInfo).ConfigureAwait(false); Assert.NotEmpty((await managementClient.GetBindingsWithSourceAsync(sourceXchange).ConfigureAwait(false)).ToList()); }
/// <summary> /// A list of all bindings in which a given exchange is the source. /// </summary> /// <param name="source"></param> /// <param name="exchange"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public static IReadOnlyList <Binding> GetBindingsWithSource( [NotNull] this IManagementClient source, [NotNull] Exchange exchange, CancellationToken cancellationToken = default ) { if (source == null) { throw new ArgumentNullException(nameof(source)); } return(source.GetBindingsWithSourceAsync(exchange, cancellationToken) .GetAwaiter() .GetResult()); }