Exemple #1
0
        public void Defaults_ConfiguresOptionsCorrectly()
        {
            var builder = new ConfigurationBuilder();

            builder.AddInMemoryCollection(new Dictionary <string, string>());
            var configuration = builder.Build().GetSection(BindingServiceOptions.PREFIX);
            var options       = new BindingServiceOptions(configuration);

            options.PostProcess();

            Assert.Equal(1, options.InstanceCount);
            Assert.Equal(0, options.InstanceIndex);
            Assert.False(options.OverrideCloudConnectors);
            Assert.Empty(options.DynamicDestinations);
            Assert.Null(options.DefaultBinder);
            Assert.Equal(30, options.BindingRetryInterval);
            Assert.Empty(options.Binders);
            Assert.Empty(options.Bindings);
            Assert.Null(options.GetBinder("foobar"));
            Assert.NotNull(options.GetBindingOptions("foobar")); // Creates binding with that name using defaults
            Assert.Equal("foobar", options.GetBindingDestination("foobar"));
            Assert.NotNull(options.GetConsumerOptions("foobar"));
            Assert.Null(options.GetGroup("foobar"));
            Assert.NotNull(options.GetProducerOptions("foobar"));
        }
Exemple #2
0
        public void Mixture_Default_NonDefault_ConfiguresOptionsCorrectly()
        {
            var builder = new ConfigurationBuilder();

            builder.AddInMemoryCollection(new Dictionary <string, string>()
            {
                { "spring:cloud:stream:instanceIndex", "2" },
                { "spring:cloud:stream:dynamicDestinations:0", "dynamicDestinations" },
                { "spring:cloud:stream:overrideCloudConnectors", "true" },
                { "spring:cloud:stream:bindingRetryInterval", "100" },
            });

            var configuration = builder.Build().GetSection(BindingServiceOptions.PREFIX);
            var options       = new BindingServiceOptions(configuration);

            options.PostProcess();

            Assert.Equal(1, options.InstanceCount);
            Assert.Equal(2, options.InstanceIndex);
            Assert.True(options.OverrideCloudConnectors);
            Assert.Single(options.DynamicDestinations);
            Assert.Equal("dynamicDestinations", options.DynamicDestinations[0]);
            Assert.Null(options.DefaultBinder);
            Assert.Equal(100, options.BindingRetryInterval);
            Assert.Empty(options.Binders);
            Assert.Empty(options.Bindings);
            Assert.Null(options.GetBinder("foobar"));
            Assert.NotNull(options.GetBindingOptions("foobar")); // Creates binding with that name using defaults
            Assert.Equal("foobar", options.GetBindingDestination("foobar"));
            Assert.NotNull(options.GetConsumerOptions("foobar"));
            Assert.Null(options.GetGroup("foobar"));
            Assert.NotNull(options.GetProducerOptions("foobar"));
        }