Example #1
0
        public void when_create_consumer_with_invalid_argument_it_should_fail()
        {
            var factory = new DefaultApiConsumerFactory(
                Mock.Of <IConsumerFactory>(),
                Mock.Of <IConsumerConfigurator>(),
                Mock.Of <IDeserializerFactory>(),
                Mock.Of <ILoggerFactory>());
            var config = new ConsumerConfig();
            var api    = Mock.Of <IIngressApi>();

            Action sut = () => factory.Create <int, string>(config, api);

            config = null;
            sut.Should().ThrowExactly <ArgumentNullException>();
            config = new ConsumerConfig();

            api = null;
            sut.Should().ThrowExactly <ArgumentNullException>();
        }
Example #2
0
        public void when_create_consumer_it_should_create_consumer()
        {
            var created = 0;

            var consumerFactoryMock = new Mock <IConsumerFactory>();

            consumerFactoryMock
            .Setup(
                factory => factory.Create <int, string>(
                    It.IsAny <ConsumerConfig>(),
                    It.IsAny <IConsumerConfigurator>(),
                    It.IsAny <IDeserializerFactory>()))
            .Callback(() => created++)
            .Returns(Mock.Of <IConsumer <int, string> >);

            var sut = new DefaultApiConsumerFactory(
                consumerFactoryMock.Object,
                Mock.Of <IConsumerConfigurator>(),
                Mock.Of <IDeserializerFactory>(),
                Mock.Of <ILoggerFactory>());

            sut.Create <int, string>(new ConsumerConfig(), Mock.Of <IIngressApi>());
            created.Should().Be(expected: 1, "one consumer should be created");
        }