Пример #1
0
        public void LogProduceError_Envelope_Logged()
        {
            var envelope = new OutboundEnvelope(
                null,
                new MessageHeaderCollection
            {
                { DefaultMessageHeaders.MessageType, "Message.Type" },
                { DefaultMessageHeaders.MessageId, "1234" },
                { KafkaMessageHeaders.KafkaMessageKey, "key1234" }
            },
                new KafkaProducerEndpoint("test1"),
                true,
                new KafkaOffset("topic2", 2, 42));

            var expectedMessage =
                "Error occurred producing the message. | " +
                "endpointName: test1, " +
                "messageType: Message.Type, " +
                "messageId: 1234, " +
                "offset: (null), " +
                "kafkaKey: key1234";

            _outboundLogger.LogProduceError(envelope, new InvalidDataException());

            _loggerSubstitute.Received(LogLevel.Warning, typeof(InvalidDataException), expectedMessage, 1032);
        }
Пример #2
0
        public void LogProduceError_Envelope_Logged()
        {
            var envelope = new OutboundEnvelope(
                null,
                new MessageHeaderCollection
            {
                { DefaultMessageHeaders.MessageType, "Message.Type" },
                { DefaultMessageHeaders.MessageId, "1234" }
            },
                new TestProducerEndpoint("test1"),
                true,
                new TestOffset("a", "42"));

            var expectedMessage =
                "Error occurred producing the message. | " +
                "endpointName: test1, " +
                "messageType: Message.Type, " +
                "messageId: 1234, " +
                "unused1: (null), " +
                "unused2: (null)";

            _outboundLogger.LogProduceError(envelope, new InvalidDataException());

            _loggerSubstitute.Received(LogLevel.Warning, typeof(InvalidDataException), expectedMessage, 1032);
        }