Example #1
0
        public void TryParse_ShouldReturnFalseWhenThePacketTypeIsNotCorrect()
        {
            TransceiverMessage message;

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

            result.ShouldBeFalse();
        }
Example #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);
            }
        }
Example #3
0
        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();
        }