Beispiel #1
0
        public void contructor_test()
        {
            var topic   = "this is my topic";
            var qos     = MqttQualityOfServiceLevel.AtMostOnce;
            var options = new MqttClientOptionsBuilder().WithTcpServer("localhost").Build();
            var actual  = new MQTTSink(options, topic);

            Assert.AreEqual(topic, actual.Topic);
            Assert.AreEqual(qos, actual.QoS);
        }
Beispiel #2
0
        public void emit_test()
        {
            var topic    = "this is my topic";
            var options  = new MqttClientOptionsBuilder().WithTcpServer("localhost").Build();
            var sink     = new MQTTSink(options, topic);
            var logEvent = new Events.LogEvent(System.DateTimeOffset.Now, Events.LogEventLevel.Error, null,
                                               new Events.MessageTemplate("@{payload}", new Parsing.MessageTemplateToken[] { }), new Events.LogEventProperty[] { });

            sink.Emit(logEvent);

            System.Threading.Thread.Sleep(100);

            var actual = messageHandler.ApplicationMessages.Where(p => p.Topic == topic);

            Assert.AreEqual(1, actual.Count());;

            var payload = LogMqttMessagePayload.GetPayload(actual.FirstOrDefault().ConvertPayloadToString());

            Assert.AreEqual("@{payload}", payload.MessageTemplate);
            Assert.AreEqual("Error", payload.Level);
        }