Esempio n. 1
0
        public void returns_expected_when_nothing_has_been_registered()
        {
            var sut    = new ProducerFactoryBuilder().Build();
            var result = sut.Get("foo");

            Assert.Null(result);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }