Exemple #1
0
        public void Read_CompleteOutbound_MessageTypeSet()
        {
            var reader =
                new ConfigurationReader(_serviceProvider)
                .Read(ConfigFileHelper.GetConfigSection("outbound.complete"));

            reader.Outbound.First().MessageType.Should().Be(typeof(IIntegrationEvent));
        }
Exemple #2
0
        public void Read_CompleteOutbound_ConnectorTypeSet()
        {
            var reader =
                new ConfigurationReader(_serviceProvider)
                .Read(ConfigFileHelper.GetConfigSection("outbound.complete"));

            reader.Outbound.Skip(1).First().ConnectorType.Should().Be(typeof(DeferredOutboundConnector));
        }
Exemple #3
0
        public void Read_CompleteInbound_ErrorPoliciesAdded()
        {
            var reader =
                new ConfigurationReader(_serviceProvider)
                .Read(ConfigFileHelper.GetConfigSection("inbound.complete"));

            reader.Inbound.First().ErrorPolicies.Should().HaveCount(2);
        }
Exemple #4
0
        public void ReadAndApply_SimpleOutbound_OutboundAdded()
        {
            new ConfigurationReader(_serviceProvider)
            .Read(ConfigFileHelper.GetConfigSection("outbound.simplest"))
            .Apply(_builder);

            _builder.ReceivedWithAnyArgs(1).AddOutbound(null, null, null);
        }
Exemple #5
0
        public void Read_SimpleOutbound_DefaultMessageType()
        {
            var reader =
                new ConfigurationReader(_serviceProvider)
                .Read(ConfigFileHelper.GetConfigSection("outbound.simplest"));

            reader.Outbound.First().MessageType.Should().Be(typeof(object));
        }
Exemple #6
0
        public void Read_SimplestInbound_EndpointAdded()
        {
            var reader =
                new ConfigurationReader(_serviceProvider)
                .Read(ConfigFileHelper.GetConfigSection("inbound.simplest"));

            reader.Inbound.Count.Should().Be(2);
            reader.Inbound.First().Endpoint.Should().NotBeNull();
        }
Exemple #7
0
        public void Read_CompleteInbound_EndpointNamesSet()
        {
            var reader =
                new ConfigurationReader(_serviceProvider)
                .Read(ConfigFileHelper.GetConfigSection("inbound.complete"));

            var endpoint = (KafkaConsumerEndpoint)reader.Inbound.Skip(1).First().Endpoint;

            endpoint.Names.Should().BeEquivalentTo("inbound-endpoint1", "inbound-endpoint2");
        }
Exemple #8
0
        public void Read_CompleteInbound_EndpointSubPropertySet()
        {
            var reader =
                new ConfigurationReader(_serviceProvider)
                .Read(ConfigFileHelper.GetConfigSection("inbound.complete"));

            var endpoint = (KafkaConsumerEndpoint)reader.Inbound.First().Endpoint;

            endpoint.Configuration.AutoOffsetReset.Should().Be(AutoOffsetReset.Earliest);
        }
Exemple #9
0
        public void Read_CompleteOutbound_CustomSerializerSet()
        {
            var reader =
                new ConfigurationReader(_serviceProvider)
                .Read(ConfigFileHelper.GetConfigSection("outbound.complete"));

            var endpoint = reader.Outbound.First().Endpoint;

            endpoint.Serializer.Should().BeOfType <FakeSerializer>();
        }
Exemple #10
0
        public void Read_SimplestInbound_DefaultSerializer()
        {
            var reader =
                new ConfigurationReader(_serviceProvider)
                .Read(ConfigFileHelper.GetConfigSection("inbound.simplest"));

            var endpoint = reader.Inbound.First().Endpoint;

            endpoint.Serializer.Should().NotBeNull();
        }
Exemple #11
0
        public void Read_SimplestInbound_EndpointNameSet()
        {
            var reader =
                new ConfigurationReader(_serviceProvider)
                .Read(ConfigFileHelper.GetConfigSection("inbound.simplest"));

            var endpoint = reader.Inbound.Skip(1).First().Endpoint;

            endpoint.Name.Should().Be("inbound-endpoint2");
        }
Exemple #12
0
        public void Read_CompleteInbound_SettingsBatchSet()
        {
            var reader =
                new ConfigurationReader(_serviceProvider)
                .Read(ConfigFileHelper.GetConfigSection("inbound.complete"));

            var batchSettings = reader.Inbound.First().Settings.Batch;

            batchSettings.Should().NotBeNull();
        }
Exemple #13
0
        public void Read_SimplestOutbound_ChunkSizeSet()
        {
            var reader =
                new ConfigurationReader(_serviceProvider)
                .Read(ConfigFileHelper.GetConfigSection("outbound.complete"));

            var endpoint = (KafkaProducerEndpoint)reader.Outbound.First().Endpoint;

            endpoint.Chunk.Size.Should().Be(100000);
        }
Exemple #14
0
        public void Read_SimplestInbound_CorrectEndpointType()
        {
            var reader =
                new ConfigurationReader(_serviceProvider)
                .Read(ConfigFileHelper.GetConfigSection("inbound.simplest"));

            var endpoint = reader.Inbound.First().Endpoint;

            endpoint.Should().BeOfType <KafkaConsumerEndpoint>();
        }
Exemple #15
0
        public void Read_CompleteOutbound_CustomSerializerPropertySet()
        {
            var reader =
                new ConfigurationReader(_serviceProvider)
                .Read(ConfigFileHelper.GetConfigSection("outbound.complete"));

            var serializer = (FakeSerializer)reader.Outbound.First().Endpoint.Serializer;

            serializer.Settings.Mode.Should().Be(4);
        }
Exemple #16
0
        public void Read_SimplestOutbound_DefaultChunkSize()
        {
            var reader =
                new ConfigurationReader(_serviceProvider)
                .Read(ConfigFileHelper.GetConfigSection("outbound.simplest"));

            var endpoint = (KafkaProducerEndpoint)reader.Outbound.First().Endpoint;

            endpoint.Chunk.Size.Should().Be(int.MaxValue);
        }
Exemple #17
0
        public void Read_CompleteInbound_SettingsConsumersSet()
        {
            var reader =
                new ConfigurationReader(_serviceProvider)
                .Read(ConfigFileHelper.GetConfigSection("inbound.complete"));

            var settings = reader.Inbound.First().Settings;

            settings.Consumers.Should().Be(3);
        }
Exemple #18
0
        public void Read_CompleteOutbound_EndpointSubPropertySet()
        {
            var reader =
                new ConfigurationReader(_serviceProvider)
                .Read(ConfigFileHelper.GetConfigSection("outbound.complete"));

            var endpoint = (KafkaProducerEndpoint)reader.Outbound.First().Endpoint;

            endpoint.Configuration.EnableBackgroundPoll.Should().BeFalse();
        }
Exemple #19
0
        public void Read_CompleteInbound_SettingsBatchPropertiesSet()
        {
            var reader =
                new ConfigurationReader(_serviceProvider)
                .Read(ConfigFileHelper.GetConfigSection("inbound.complete"));

            var batchSettings = reader.Inbound.First().Settings.Batch;

            batchSettings.Size.Should().Be(5);
            batchSettings.MaxWaitTime.Should().Be(TimeSpan.FromMilliseconds(2500));
        }
Exemple #20
0
        public void Read_CompleteInbound_ErrorPolicyMaxFailedAttemptsSet()
        {
            var reader =
                new ConfigurationReader(_serviceProvider)
                .Read(ConfigFileHelper.GetConfigSection("inbound.complete"));

            var policy = reader.Inbound.First().ErrorPolicies.First();

            policy.CanHandle(new InboundMessage(null, new[] { new MessageHeader(MessageHeader.FailedAttemptsKey, "3") }, null, null, true), new ArgumentException()).Should().BeTrue();
            policy.CanHandle(new InboundMessage(null, new[] { new MessageHeader(MessageHeader.FailedAttemptsKey, "6") }, null, null, true), new ArgumentException()).Should().BeFalse();
        }
Exemple #21
0
        public void Read_CompleteInbound_ErrorPolicyConstructorParameterSet()
        {
            var reader =
                new ConfigurationReader(_serviceProvider)
                .Read(ConfigFileHelper.GetConfigSection("inbound.complete"));

            var policy = (RetryErrorPolicy)reader.Inbound.First().ErrorPolicies.First();

            ((TimeSpan)policy.GetType().GetField("_delayIncrement", BindingFlags.NonPublic | BindingFlags.Instance)
             .GetValue(policy)).Should().Be(TimeSpan.FromMinutes(5));
        }
Exemple #22
0
        public void Read_CompleteInbound_ErrorPolicyExcludeSet()
        {
            var reader =
                new ConfigurationReader(_serviceProvider)
                .Read(ConfigFileHelper.GetConfigSection("inbound.complete"));

            var policy = reader.Inbound.First().ErrorPolicies.First();

            policy.CanHandle(new InboundMessage(null, null, null, null, true), new ArgumentException()).Should().BeTrue();
            policy.CanHandle(new InboundMessage(null, null, null, null, true), new ArgumentNullException()).Should().BeFalse();
        }
Exemple #23
0
        public void Read_CompleteOutbound_DefaultSerializerPropertiesSet()
        {
            var reader =
                new ConfigurationReader(_serviceProvider)
                .Read(ConfigFileHelper.GetConfigSection("outbound.complete"));

            var serializer = (JsonMessageSerializer)reader.Outbound.Skip(1).First().Endpoint.Serializer;

            serializer.Encoding.Should().Be(MessageEncoding.Unicode);
            serializer.Settings.Formatting.Should().Be(Formatting.Indented);
        }
Exemple #24
0
        public void ReadAndApply_CompleteOutbound_AddOutboundWithCorrectTypes()
        {
            new ConfigurationReader(_serviceProvider)
            .Read(ConfigFileHelper.GetConfigSection("outbound.complete"))
            .Apply(_builder);

            _builder.Received(1).AddOutbound(
                typeof(IIntegrationEvent),
                Arg.Any <KafkaProducerEndpoint>(),
                null);
            _builder.Received(1).AddOutbound(
                typeof(IIntegrationCommand),
                Arg.Any <KafkaProducerEndpoint>(),
                typeof(DeferredOutboundConnector));
        }
Exemple #25
0
        public void ReadAndApply_CompleteInbound_AddInboundWithCorrectTypes()
        {
            new ConfigurationReader(_serviceProvider)
            .Read(ConfigFileHelper.GetConfigSection("inbound.complete"))
            .Apply(_builder);

            // TODO: Should check policies in first call
            _builder.Received(1).AddInbound(
                Arg.Any <KafkaConsumerEndpoint>(),
                null,
                Arg.Any <Func <ErrorPolicyBuilder, IErrorPolicy> >(),
                Arg.Any <InboundConnectorSettings>());
            _builder.Received(1).AddInbound(
                Arg.Any <KafkaConsumerEndpoint>(),
                typeof(LoggedInboundConnector),
                Arg.Is <Func <ErrorPolicyBuilder, IErrorPolicy> >(f => f.Invoke(null) == null));
        }