Beispiel #1
0
        public void Validate_InvalidConfiguration_ExceptionThrown()
        {
            var endpoint = new MqttConsumerEndpoint("topic")
            {
                Configuration = new MqttClientConfig()
            };

            Action act = () => endpoint.Validate();

            act.Should().ThrowExactly <EndpointConfigurationException>();
        }
Beispiel #2
0
        public void Equals_SameEndpointInstance_TrueIsReturned()
        {
            var endpoint = new MqttConsumerEndpoint("topic")
            {
                Configuration =
                {
                    ClientId = "client1"
                }
            };

            endpoint.Equals(endpoint).Should().BeTrue();
        }
Beispiel #3
0
        public void Validate_MissingTopic_ExceptionThrown()
        {
            var endpoint = new MqttConsumerEndpoint
            {
                Configuration = new MqttClientConfig
                {
                    ChannelOptions = new MqttClientTcpOptions
                    {
                        Server = "test-server"
                    }
                }
            };

            Action act = () => endpoint.Validate();

            act.Should().ThrowExactly <EndpointConfigurationException>();
        }
Beispiel #4
0
        public void Validate_DynamicTypeSerializerOnV500_NoExceptionThrown()
        {
            var endpoint = new MqttConsumerEndpoint("topic")
            {
                Configuration = new MqttClientConfig
                {
                    ChannelOptions = new MqttClientTcpOptions
                    {
                        Server = "test-server"
                    },
                    ProtocolVersion = MqttProtocolVersion.V500
                },
                Serializer = new JsonMessageSerializer()
            };

            Action act = () => endpoint.Validate();

            act.Should().NotThrow();
        }
Beispiel #5
0
        public void Validate_ChainedRetryPolicyWithMultipleRetriesOnV500_NoExceptionThrown()
        {
            var endpoint = new MqttConsumerEndpoint("topic")
            {
                Configuration = new MqttClientConfig
                {
                    ChannelOptions = new MqttClientTcpOptions
                    {
                        Server = "test-server"
                    },
                    ProtocolVersion = MqttProtocolVersion.V500
                },
                ErrorPolicy = new ErrorPolicyChain(new RetryErrorPolicy().MaxFailedAttempts(10))
            };

            Action act = () => endpoint.Validate();

            act.Should().NotThrow();
        }
        public void Validate_ChainedErrorPoliciesOnDefaultV500_NoExceptionThrown()
        {
            var endpoint = new MqttConsumerEndpoint("topic")
            {
                Configuration = new MqttClientConfig
                {
                    ChannelOptions = new MqttClientTcpOptions
                    {
                        Server = "test-server"
                    },
                    ProtocolVersion = MqttProtocolVersion.V500
                },
                ErrorPolicy = new ErrorPolicyChain(new RetryErrorPolicy(), new SkipMessageErrorPolicy())
            };

            Action act = () => endpoint.Validate();

            act.Should().NotThrow();
        }
        public void Validate_RetryPolicyWithMultipleRetriesOnV311_ExceptionThrown()
        {
            var endpoint = new MqttConsumerEndpoint("topic")
            {
                Configuration = new MqttClientConfig
                {
                    ChannelOptions = new MqttClientTcpOptions
                    {
                        Server = "test-server"
                    },
                    ProtocolVersion = MqttProtocolVersion.V311
                },
                ErrorPolicy = new RetryErrorPolicy().MaxFailedAttempts(10)
            };

            Action act = () => endpoint.Validate();

            act.Should().ThrowExactly <EndpointConfigurationException>();
        }
Beispiel #8
0
        public void Equals_DifferentConfiguration_FalseIsReturned()
        {
            var endpoint1 = new MqttConsumerEndpoint("topic")
            {
                Configuration =
                {
                    ClientId = "client1"
                }
            };

            var endpoint2 = new MqttConsumerEndpoint("topic")
            {
                Configuration =
                {
                    ClientId = "client2"
                }
            };

            endpoint1.Equals(endpoint2).Should().BeFalse();
        }
Beispiel #9
0
        public void Validate_ChainedMovePolicyWithMultipleRetriesOnV311_ExceptionThrown()
        {
            var endpoint = new MqttConsumerEndpoint("topic")
            {
                Configuration = new MqttClientConfig
                {
                    ChannelOptions = new MqttClientTcpOptions
                    {
                        Server = "test-server"
                    },
                    ProtocolVersion = MqttProtocolVersion.V311
                },
                ErrorPolicy = new ErrorPolicyChain(
                    new MoveMessageErrorPolicy(GetValidProducerEndpoint()).MaxFailedAttempts(10))
            };

            Action act = () => endpoint.Validate();

            act.Should().Throw <EndpointConfigurationException>();
        }
Beispiel #10
0
        public void Validate_RetryPolicyWithMultipleRetriesOnV311_NoExceptionThrown()
        {
            var endpoint = new MqttConsumerEndpoint("topic")
            {
                Configuration = new MqttClientConfig
                {
                    ChannelOptions = new MqttClientTcpOptions
                    {
                        Server = "test-server"
                    },
                    ProtocolVersion = MqttProtocolVersion.V311
                },
                Serializer  = new JsonMessageSerializer <TestEventOne>(),
                ErrorPolicy = new RetryErrorPolicy().MaxFailedAttempts(10)
            };

            Action act = () => endpoint.Validate();

            act.Should().NotThrow();
        }