public void TryParse_ShouldReturnFalseWhenThePacketTypeIsNotCorrect()
        {
            TransceiverMessage message;

            var buffer = new byte[] { 0x04, 0x03, 0x00, 0x01, 0x01 };
            var result = TransceiverMessage.TryParse(buffer, out message);

            result.ShouldBeFalse();
        }
Beispiel #2
0
        public override void Handle(ReceiveContext context)
        {
            TransceiverMessage message;

            if (TransceiverMessage.TryParse(context.Data, out message))
            {
                context.Observable.OnNext(new MessageReceived <TransceiverMessage>(message));
            }
            else
            {
                InvokeNextHandler(context);
            }
        }
        public void TryParse_ShouldConstructCorrectMessageForErrorResponse()
        {
            TransceiverMessage message;

            var buffer = new byte[] { 0x04, 0x02, 0x00, 0x01, 0x00 };
            var result = TransceiverMessage.TryParse(buffer, out message);

            result.ShouldBeTrue();
            message.PacketLength.ShouldEqual((byte)0x04);
            message.PacketType.ShouldEqual(PacketType.TransceiverMessage);
            message.SequenceNumber.ShouldEqual((byte)0x01);
            message.SubType.ShouldEqual(TransceiverMessageSubType.Error);
            message.Response.ShouldBeNull();
        }