コード例 #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>();
        }
コード例 #8
0
        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
ファイル: IngressApi.cs プロジェクト: Eshva/Eshva.Poezd
        /// <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);
        }
コード例 #16
0
        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>();
        }