public void GivenBusInitializerOptionsWhenSetOptionsShouldLoadOptions() { var configuration = new ConfigurationBuilder().Build(); var connectionOptions = new BusConnectionOptions { ConnectionMaxRetry = 5, MessageMaxRetry = 5, PublisherBufferSize = 5, PublishMaxRetry = 5, ConsumerMaxParallelTasks = 5, ConnectionRetryDelayInMilliseconds = 5, PublisherBufferTtlInMilliseconds = 5, PublishRetryDelayInMilliseconds = 5 }; var builder = new BusInitializerOptionsBuilder(configuration); var options = builder .SetConnectionString(CONNECTION_STRING) .SetSerializer <BusSerializerStub>() .SetOptions(connectionOptions) .Build(); options.ConnectionOptions.Should().Be(connectionOptions); }
public BusInitializerOptionsBuilder SetOptions(string sectionName) { if (string.IsNullOrWhiteSpace(sectionName)) { throw new ArgumentException("Invalid section name.", nameof(sectionName)); } var options = new BusConnectionOptions(); _configuration.GetSection(sectionName).Bind(options); return(SetOptions(options)); }
public BusInitializerOptions( string connectionString, bool validateCertificate, BusConnectionOptions connectionOptions, Type serializerImplementationType, Type loggerImplementationType, IRetryBehavior retryBehavior) { ConnectionString = connectionString ?? throw new ArgumentNullException(nameof(connectionString)); ValidateCertificate = validateCertificate; ConnectionOptions = connectionOptions ?? throw new ArgumentNullException(nameof(connectionOptions)); SerializerImplementationType = serializerImplementationType ?? throw new ArgumentNullException(nameof(serializerImplementationType)); LoggerImplementationType = loggerImplementationType; RetryBehavior = retryBehavior ?? throw new ArgumentNullException(nameof(retryBehavior)); }
public void GivenBusInitializerOptionsWhenSetOptionsBySectionShouldLoadOptions() { const string KEY = "ConnectionOptions"; var configuration = new ConfigurationBuilder().AddInMemoryCollection(new[] { new KeyValuePair <string, string>($"{KEY}:{nameof(BusConnectionOptions.ConnectionMaxRetry)}", "5"), new KeyValuePair <string, string>($"{KEY}:{nameof(BusConnectionOptions.MessageMaxRetry)}", "5"), new KeyValuePair <string, string>( $"ConnectionOptions:{nameof(BusConnectionOptions.PublisherBufferSize)}", "5"), new KeyValuePair <string, string>($"{KEY}:{nameof(BusConnectionOptions.PublishMaxRetry)}", "5"), new KeyValuePair <string, string>( $"{KEY}:{nameof(BusConnectionOptions.ConsumerMaxParallelTasks)}", "5"), new KeyValuePair <string, string>( $"{KEY}:{nameof(BusConnectionOptions.ConnectionRetryDelayInMilliseconds)}", "5"), new KeyValuePair <string, string>( $"{KEY}:{nameof(BusConnectionOptions.PublisherBufferTtlInMilliseconds)}", "5"), new KeyValuePair <string, string>( $"{KEY}:{nameof(BusConnectionOptions.PublishRetryDelayInMilliseconds)}", "5"), }).Build(); var connectionOptions = new BusConnectionOptions { ConnectionMaxRetry = 5, MessageMaxRetry = 5, PublisherBufferSize = 5, PublishMaxRetry = 5, ConsumerMaxParallelTasks = 5, ConnectionRetryDelayInMilliseconds = 5, PublisherBufferTtlInMilliseconds = 5, PublishRetryDelayInMilliseconds = 5 }; var builder = new BusInitializerOptionsBuilder(configuration); var options = builder .SetConnectionString(CONNECTION_STRING) .SetSerializer <BusSerializerStub>() .SetOptions(KEY) .Build(); options.Should().NotBeNull(); options.ConnectionOptions.Should().Be(connectionOptions); }
public BusInitializerOptionsBuilder SetOptions(BusConnectionOptions options) { _options = options ?? throw new ArgumentNullException(nameof(options)); return(this); }