コード例 #1
0
        public void throws_expected_when_adding_multiple_producers_with_same_name()
        {
            var sut = new ProducerFactoryBuilder().Build();

            sut.ConfigureProducer(
                producerName: "foo",
                configuration: new ProducerConfigurationBuilder().Build(),
                outgoingMessageRegistry: new OutgoingMessageRegistry()
                );

            Assert.Throws <ProducerFactoryException>(() => sut.ConfigureProducer(
                                                         producerName: "foo",
                                                         configuration: new ProducerConfigurationBuilder().Build(),
                                                         outgoingMessageRegistry: new OutgoingMessageRegistry()
                                                         ));
        }
コード例 #2
0
        public void returns_expected_when_getting_by_an_unknown_name()
        {
            var producerConfigurationStub   = new ProducerConfigurationBuilder().Build();
            var outgoingMessageRegistryStub = new OutgoingMessageRegistry();

            var sut = new ProducerFactoryBuilder().Build();

            sut.ConfigureProducer("foo", producerConfigurationStub, outgoingMessageRegistryStub);

            var result = sut.Get("bar");

            Assert.Null(result);
        }
コード例 #3
0
        public void returns_expected_when_getting_by_a_known_name()
        {
            var producerConfigurationStub   = A.ValidProducerConfiguration.Build();
            var outgoingMessageRegistryStub = new OutgoingMessageRegistry();

            var sut = new ProducerFactoryBuilder().Build();

            sut.ConfigureProducer("foo", producerConfigurationStub, outgoingMessageRegistryStub);

            var result = sut.Get("foo", NullLoggerFactory.Instance);

            Assert.IsType <Producer>(result);
            Assert.NotNull(result);
        }
コード例 #4
0
        public void when_disposing_the_factory_all_kafka_producers_are_also_disposed()
        {
            var spy = new KafkaProducerSpy();

            using (var sut = new ProducerFactoryBuilder().Build())
            {
                var producerConfiguration = new ProducerConfigurationBuilder()
                                            .WithKafkaProducerFactory(() => spy)
                                            .Build();

                sut.ConfigureProducer(
                    producerName: "foo",
                    configuration: producerConfiguration,
                    outgoingMessageRegistry: new OutgoingMessageRegistry()
                    );

                sut.Get("foo");
            }

            Assert.True(spy.WasDisposed);
        }