示例#1
0
 public static IngressApiConfiguration With(
     this IngressApiConfiguration configuration,
     Action <IngressApiConfiguration> updater)
 {
     updater(configuration);
     return(configuration);
 }
示例#2
0
        public void when_key_type_set_it_should_be_set_in_configuration()
        {
            var configuration = new IngressApiConfiguration();
            var sut           = new IngressApiConfigurator(configuration);

            sut.WithMessageKey <int>().Should().BeSameAs(sut);
            configuration.MessageKeyType.Should().Be <int>();
        }
示例#3
0
        public void when_enter_pipe_fitter_set_it_should_be_set_in_configuration()
        {
            var configuration = new IngressApiConfiguration();
            var sut           = new IngressApiConfigurator(configuration);

            sut.WithPipeFitter <StabPipeFitter>().Should().BeSameAs(sut);
            configuration.PipeFitterType.Should().Be <StabPipeFitter>();
        }
示例#4
0
        public void when_payload_type_set_it_should_be_set_in_configuration()
        {
            var configuration = new IngressApiConfiguration();
            var sut           = new IngressApiConfigurator(configuration);

            sut.WithMessagePayload <string>().Should().BeSameAs(sut);
            configuration.MessagePayloadType.Should().Be <string>();
        }
示例#5
0
        public void when_message_type_registry_set_it_should_be_set_in_configuration()
        {
            var configuration = new IngressApiConfiguration();
            var sut           = new IngressApiConfigurator(configuration);

            sut.WithMessageTypesRegistry <MessageTypesRegistry1>().Should().BeSameAs(sut);
            configuration.MessageTypesRegistryType.Should().Be <MessageTypesRegistry1>();
        }
示例#6
0
        public void when_queue_name_patterns_provider_set_it_should_be_set_in_configuration()
        {
            var configuration = new IngressApiConfiguration();
            var sut           = new IngressApiConfigurator(configuration);

            sut.WithQueueNamePatternsProvider <QueueNamePatternsProvider>().Should().BeSameAs(sut);
            configuration.QueueNamePatternsProviderType.Should().Be <QueueNamePatternsProvider>();
        }
示例#7
0
        public void when_handler_registry_set_it_should_be_set_in_configuration()
        {
            var configuration = new IngressApiConfiguration();
            var sut           = new IngressApiConfigurator(configuration);

            sut.WithHandlerRegistry <HandlerRegistry>().Should().BeSameAs(sut);
            configuration.HandlerRegistryType.Should().Be <HandlerRegistry>();
        }
        public void when_same_api_added_second_time_it_should_fail()
        {
            var    configuration = new BrokerIngressConfiguration();
            var    api           = new IngressApiConfiguration();
            Action sut           = () => configuration.AddApi(api);

            sut.Should().NotThrow();
            sut.Should().ThrowExactly <PoezdConfigurationException>();
        }
示例#9
0
        public void when_id_set_it_should_be_set_in_configuration()
        {
            var          configuration = new IngressApiConfiguration();
            var          sut           = new IngressApiConfigurator(configuration);
            const string expected      = "id";

            sut.WithId(expected).Should().BeSameAs(sut);
            configuration.Id.Should().Be(expected);
        }
示例#10
0
        public void when_pipe_fitter_set_more_than_once_it_should_fail()
        {
            var    configuration = new IngressApiConfiguration();
            var    configurator  = new IngressApiConfigurator(configuration);
            Action sut           = () => configurator.WithPipeFitter <StabPipeFitter>();

            sut.Should().NotThrow();
            configuration.PipeFitterType.Should().Be <StabPipeFitter>();
            EnsureSecondCallOfConfigurationMethodFails(sut);
        }
示例#11
0
        public void when_payload_type_set_more_than_once_it_should_fail()
        {
            var    configuration = new IngressApiConfiguration();
            var    configurator  = new IngressApiConfigurator(configuration);
            Action sut           = () => configurator.WithMessagePayload <string>();

            sut.Should().NotThrow();
            configuration.MessagePayloadType.Should().Be <string>();
            EnsureSecondCallOfConfigurationMethodFails(sut);
        }
示例#12
0
        public void when_message_type_registry_set_more_than_once_it_should_fail()
        {
            var    configuration = new IngressApiConfiguration();
            var    configurator  = new IngressApiConfigurator(configuration);
            Action sut           = () => configurator.WithMessageTypesRegistry <MessageTypesRegistry1>();

            sut.Should().NotThrow();
            configuration.MessageTypesRegistryType.Should().Be <MessageTypesRegistry1>();
            EnsureSecondCallOfConfigurationMethodFails(sut);
        }
示例#13
0
        public void when_queue_name_patterns_provider_set_more_than_once_it_should_fail()
        {
            var    configuration = new IngressApiConfiguration();
            var    configurator  = new IngressApiConfigurator(configuration);
            Action sut           = () => configurator.WithQueueNamePatternsProvider <QueueNamePatternsProvider>();

            sut.Should().NotThrow();
            configuration.QueueNamePatternsProviderType.Should().Be <QueueNamePatternsProvider>();
            EnsureSecondCallOfConfigurationMethodFails(sut);
        }
示例#14
0
        public void when_id_set_more_than_once_it_should_fail()
        {
            var          configuration = new IngressApiConfiguration();
            var          configurator  = new IngressApiConfigurator(configuration);
            const string expected      = "id";
            Action       sut           = () => configurator.WithId(expected);

            sut.Should().NotThrow();
            configuration.Id.Should().Be(expected);
            EnsureSecondCallOfConfigurationMethodFails(sut);
        }
示例#15
0
        /// <summary>
        /// Constructs a new instance of ingress API.
        /// </summary>
        /// <param name="configuration">
        /// The ingress API configuration.
        /// </param>
        /// <param name="serviceProvider">
        /// Service provider.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// One of arguments is not specified.
        /// </exception>
        public IngressApi([NotNull] IngressApiConfiguration configuration, [NotNull] IDiContainerAdapter serviceProvider)
        {
            Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            _queueNamePatternsProvider = GetQueueNamePatternsProvider(serviceProvider);
            MessageTypesRegistry       = GetMessageTypesRegistry(serviceProvider);
            HandlerRegistry            = GetHandlerRegistry(serviceProvider);
            PipeFitter = GetIngressPipeFitter(serviceProvider);
        }
        public void when_api_with_same_id_added_it_should_fail()
        {
            var configuration = new BrokerIngressConfiguration();

            const string sameId = "same id";
            var          api1   = new IngressApiConfiguration {
                Id = sameId
            };
            Action sut1 = () => configuration.AddApi(api1);

            sut1.Should().NotThrow();

            var api2 = new IngressApiConfiguration {
                Id = sameId
            };
            Action sut2 = () => configuration.AddApi(api2);

            sut2.Should().ThrowExactly <PoezdConfigurationException>();
        }