/// <summary> /// Configures Rebus to use Correlate as the Correlation ID provider by resolving Correlate dependencies using the specified <paramref name="serviceProvider"/>. To make sure all required dependencies are registered, use the registration extensions from the <c>Correlate.DependencyInjection</c> package. /// </summary> /// <param name="configurer">The options configurer.</param> /// <param name="serviceProvider">The service provider to resolve Correlate dependencies with.</param> /// <returns>The <see cref="OptionsConfigurer"/> instance.</returns> public static OptionsConfigurer EnableCorrelate(this OptionsConfigurer configurer, IServiceProvider serviceProvider) { if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } return(configurer.EnableCorrelate(new DependencyResolverAdapter(serviceProvider.GetService))); }
public void When_configuring_instance_without_configurer_it_should_throw() { OptionsConfigurer configurer = null; // ReSharper disable once ExpressionIsAlwaysNull Action act = () => configurer.EnableCorrelate(new DependencyResolverAdapter(_ => null)); // Assert act.Should() .Throw <ArgumentNullException>() .Where(exception => exception.ParamName == nameof(configurer)); }
public void When_configuring_instance_without_configurer_it_should_throw() { OptionsConfigurer configurer = null; // ReSharper disable once ExpressionIsAlwaysNull Action act = () => configurer.EnableCorrelate(new ServiceCollection().BuildServiceProvider()); // Assert act.Should() .Throw <ArgumentNullException>() .Where(exception => exception.ParamName == nameof(configurer)); }