public static BrokerIngressConfigurator WithTestDriver(this BrokerIngressConfigurator ingress) { IBrokerIngressDriverConfigurator driverConfigurator = ingress; driverConfigurator.SetDriver(Mock.Of <IBrokerIngressDriver>(), Mock.Of <IMessageRouterConfigurationPart>()); return(ingress); }
public static BrokerIngressConfigurator WithSpecificDriver(this BrokerIngressConfigurator ingress, IBrokerIngressDriver driver) { IBrokerIngressDriverConfigurator driverConfigurator = ingress; driverConfigurator.SetDriver(driver, Mock.Of <IMessageRouterConfigurationPart>()); return(ingress); }
public void when_queue_name_matcher_set_it_should_be_set_in_configuration() { var configuration = new BrokerIngressConfiguration(); var sut = new BrokerIngressConfigurator(configuration); sut.WithQueueNameMatcher <StabQueueNameMatcher>().Should().BeSameAs(sut); configuration.QueueNameMatcherType.Should().Be <StabQueueNameMatcher>(); }
public void when_exit_pipe_fitter_set_it_should_be_set_in_configuration() { var configuration = new BrokerIngressConfiguration(); var sut = new BrokerIngressConfigurator(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 BrokerIngressConfigurator(new BrokerIngressConfiguration()); // ReSharper disable once AssignNullToNotNullAttribute - it's a test against null. Action sut = () => configurator.AddApi(configurator: null); sut.Should().Throw <ArgumentNullException>(); }
public void when_set_kafka_driver_without_configurator_it_should_fail() { var configuration = MakeConfiguration(); var configurator = new BrokerIngressConfigurator(configuration); Action sut = () => configurator.WithKafkaDriver(configurator: null); sut.Should().ThrowExactly <ArgumentNullException>(); }
public void when_api_added_it_should_be_added_into_configuration() { var configuration = new BrokerIngressConfiguration(); var sut = new BrokerIngressConfigurator(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_queue_name_matcher_set_more_than_once_it_should_fail() { var configuration = new BrokerIngressConfiguration(); var configurator = new BrokerIngressConfigurator(configuration); Action sut = () => configurator.WithQueueNameMatcher <StabQueueNameMatcher>(); sut.Should().NotThrow(); configuration.QueueNameMatcherType.Should().Be <StabQueueNameMatcher>(); EnsureSecondCallOfConfigurationMethodFails(sut); }
public void when_exit_pipe_fitter_set_more_than_once_it_should_fail() { var configuration = new BrokerIngressConfiguration(); var configurator = new BrokerIngressConfigurator(configuration); Action sut = () => configurator.WithExitPipeFitter <StabPipeFitter>(); sut.Should().NotThrow(); configuration.ExitPipeFitterType.Should().Be <StabPipeFitter>(); EnsureSecondCallOfConfigurationMethodFails(sut); }
public void when_set_kafka_driver_it_should_set_driver_on_broker_ingress() { var configuration = MakeConfiguration(); var configurator = new BrokerIngressConfigurator(configuration); configurator.WithKafkaDriver( driverConfigurator => driverConfigurator .WithHeaderValueCodec <IHeaderValueCodec>() .WithConsumerConfig(new ConsumerConfig()) .WithConsumerConfigurator <IConsumerConfigurator>() .WithConsumerFactory <IApiConsumerFactory>() .WithDeserializerFactory <IDeserializerFactory>()); configuration.Driver.Should().BeOfType <BrokerIngressKafkaDriver>(); }
/// <summary> /// Sets Kafka driver as broker ingress driver. /// </summary> /// <param name="brokerIngress"> /// The broker ingress. /// </param> /// <param name="configurator"> /// The broker ingress Kafka driver configurator. /// </param> /// <returns> /// This broker ingress configurator. /// </returns> /// <exception cref="ArgumentNullException"> /// This broker ingress configurator is not specified. /// </exception> public static BrokerIngressConfigurator WithKafkaDriver( this BrokerIngressConfigurator brokerIngress, [NotNull] Action <BrokerIngressKafkaDriverConfigurator> configurator) { if (configurator == null) { throw new ArgumentNullException(nameof(configurator)); } var configuration = new BrokerIngressKafkaDriverConfiguration(); configurator(new BrokerIngressKafkaDriverConfigurator(configuration)); IBrokerIngressDriverConfigurator driverConfigurator = brokerIngress; driverConfigurator.SetDriver(new BrokerIngressKafkaDriver(configuration, new DefaultConsumerRegistry()), configuration); return(brokerIngress); }
private static BrokerIngressConfiguration MakeConfiguration() { var configuration = new BrokerIngressConfiguration(); var configurator = new BrokerIngressConfigurator(configuration); configurator .WithEnterPipeFitter <IPipeFitter>() .WithExitPipeFitter <IPipeFitter>() .WithQueueNameMatcher <RegexQueueNameMatcher>() .AddApi( apiConfigurator => apiConfigurator .WithHandlerRegistry <IHandlerRegistry>() .WithId("id") .WithMessageKey <int>() .WithMessagePayload <string>() .WithMessageTypesRegistry <IIngressApiMessageTypesRegistry>() .WithPipeFitter <IPipeFitter>() .WithQueueNamePatternsProvider <IQueueNamePatternsProvider>()); return(configuration); }