public static BrokerEgressConfigurator WithTestDriver(this BrokerEgressConfigurator egress)
        {
            IBrokerEgressDriverConfigurator driverConfigurator = egress;

            driverConfigurator.SetDriver(Mock.Of <IBrokerEgressDriver>(), Mock.Of <IMessageRouterConfigurationPart>());
            return(egress);
        }
        public static BrokerEgressConfigurator WithSpecificDriver(this BrokerEgressConfigurator egress, IBrokerEgressDriver driver)
        {
            IBrokerEgressDriverConfigurator driverConfigurator = egress;

            driverConfigurator.SetDriver(driver, Mock.Of <IMessageRouterConfigurationPart>());
            return(egress);
        }
Example #3
0
        public void when_set_kafka_driver_without_configurator_it_should_fail()
        {
            var    configuration = new BrokerEgressConfiguration();
            var    configurator  = new BrokerEgressConfigurator(configuration);
            Action sut           = () => configurator.WithKafkaDriver(configurator: null);

            sut.Should().ThrowExactly <ArgumentNullException>();
        }
        public void when_exit_pipe_fitter_set_it_should_be_set_in_configuration()
        {
            var configuration = new BrokerEgressConfiguration();
            var sut           = new BrokerEgressConfigurator(configuration);

            sut.WithExitPipeFitter <StabPipeFitter>().Should().BeSameAs(sut);
            configuration.ExitPipeFitterType.Should().Be <StabPipeFitter>();
        }
        public void when_null_added_as_api_it_should_fail()
        {
            var configurator = new BrokerEgressConfigurator(new BrokerEgressConfiguration());
            // ReSharper disable once AssignNullToNotNullAttribute - it's a test against null.
            Action sut = () => configurator.AddApi(configurator: null);

            sut.Should().Throw <ArgumentNullException>();
        }
        public void when_setting_null_as_driver_configuration_it_should_fail()
        {
            var configurator       = new BrokerEgressConfigurator(new BrokerEgressConfiguration());
            var driverConfigurator = (IBrokerEgressDriverConfigurator)configurator;
            // ReSharper disable once AssignNullToNotNullAttribute - it's a test against null.
            Action sut = () => driverConfigurator.SetDriver(new TestBrokerEgressDriver(new TestDriverState()), configuration: null);

            sut.Should().Throw <ArgumentNullException>();
        }
        public void when_api_added_it_should_be_added_into_configuration()
        {
            var configuration = new BrokerEgressConfiguration();
            var sut           = new BrokerEgressConfigurator(configuration);
            var expected      = new StringCreator().Get(length: 10);

            sut.AddApi(api => api.WithId(expected)).Should().BeSameAs(sut);
            configuration.Apis.Should().HaveCount(expected: 1, "an API should be added")
            .And.Subject.Single().Id.Should().Be(expected, "it should be added API instance");
        }
        public void when_exit_pipe_fitter_set_more_than_once_it_should_fail()
        {
            var    configuration = new BrokerEgressConfiguration();
            var    configurator  = new BrokerEgressConfigurator(configuration);
            Action sut           = () => configurator.WithExitPipeFitter <StabPipeFitter>();

            sut.Should().NotThrow();
            configuration.ExitPipeFitterType.Should().Be <StabPipeFitter>();
            EnsureSecondCallOfConfigurationMethodFails(sut);
        }
Example #9
0
        public void when_broker_egress_configured_with_kafka_driver_it_should_configure_in_expected_way()
        {
            var configuration = new BrokerEgressConfiguration();
            var configurator  = new BrokerEgressConfigurator(configuration);

            configurator.WithKafkaDriver(
                driver => driver
                .WithProducerConfig(new ProducerConfig())
                .WithDefaultProducerFactory()
                .WithHeaderValueCodec <IHeaderValueCodec>()
                .WithProducerFactory <IApiProducerFactory>()
                .WithSerializerFactory <ISerializerFactory>());

            configuration.Driver.Should().BeOfType <BrokerEgressKafkaDriver>("what it can be else?");
        }
        /// <summary>
        /// Sets Kafka driver as broker egress driver.
        /// </summary>
        /// <param name="brokerEgress">
        /// The broker egress.
        /// </param>
        /// <param name="configurator">
        /// The broker egress Kafka driver configurator.
        /// </param>
        /// <returns>
        /// This broker egress configurator.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// This broker egress configurator is not specified.
        /// </exception>
        public static BrokerEgressConfigurator WithKafkaDriver(
            this BrokerEgressConfigurator brokerEgress,
            [NotNull] Action <BrokerEgressKafkaDriverConfigurator> configurator)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            var configuration = new BrokerEgressKafkaDriverConfiguration();

            configurator(new BrokerEgressKafkaDriverConfigurator(configuration));
            IBrokerEgressDriverConfigurator driverConfigurator = brokerEgress;

            driverConfigurator.SetDriver(new BrokerEgressKafkaDriver(configuration, new DefaultProducerRegistry()), configuration);
            return(brokerEgress);
        }