public void IfDate_IsWrongFormatThenExceptionShouldBeThrown()
        {
            var mockMQ  = new Mock <IMessageQueue>();
            var decoder = new MQTTDecoderSnowdepth(mockMQ.Object);

            byte[] bytes = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 12, 13, 14, 15, 16, 17, 18 };

            Assert.Throws <System.FormatException>(() => decoder.Decode("gurka", "ff", "", CreateTestPayload(bytes)));
        }
        public void IfNotSummer_SnowdepthShouldSend()
        {
            var mockMQ  = new Mock <IMessageQueue>();
            var decoder = new MQTTDecoderSnowdepth(mockMQ.Object);

            byte[] bytes = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 12, 13, 14, 15, 16, 17, 18 };

            decoder.Decode("2020-11-19T14:22:36Z", "ff", "", CreateTestPayload(bytes));

            mockMQ.Verify(foo => foo.PostMessage(It.IsAny <TelemetrySnowdepth>()), Times.Once());
        }
        public void IfSnowdepth_ReceivedMatchesExpectedSentOutcome()
        {
            var mockMQ  = new Mock <IMessageQueue>();
            var decoder = new MQTTDecoderSnowdepth(mockMQ.Object);

            byte[] bytes = { 0, 1, 2, 3, 4, 5, 6, 1, 244, 9, 10, 0, 12, 13, 14, 15, 16, 17, 18 };

            decoder.Decode("2020-11-19T14:22:36Z", "ff", "", CreateTestPayload(bytes));

            mockMQ.Verify(ms => ms.PostMessage(
                              It.Is <TelemetrySnowdepth>(mo => mo.Depth == 50)
                              ), Times.Once());
        }
        public void IfSensor_IsNotOkaySnowdepthShouldNotSend()
        {
            var mockMQ  = new Mock <IMessageQueue>();
            var decoder = new MQTTDecoderSnowdepth(mockMQ.Object);

            //The byte array is needed to form the payload that PostMessage sends. Without it, the test does not work.
            //The 11th byte (11), should be 0 if the sensor is okay (see previous tests).
            byte[] bytes = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 };

            decoder.Decode("2020-11-19T14:22:36Z", "ff", "", CreateTestPayload(bytes));

            mockMQ.Verify(foo => foo.PostMessage(It.IsAny <TelemetrySnowdepth>()), Times.Never());
        }