Example #1
0
        public void TestUInt16()
        {
            var stm = new MemoryStream();
            var wrt = new RnetStreamWriter(stm);

            wrt.WriteUInt16(1);

            var expected = new byte[]
            {
                0x01,
                0x00,
            };

            Assert.IsTrue(stm.ToArray().SequenceEqual(expected));
        }
Example #2
0
        public void TestFullMessage()
        {
            var stm = new MemoryStream();
            var wrt = new RnetStreamWriter(stm);

            wrt.BeginMessage(RnetDeviceId.RootController, RnetDeviceId.External, RnetMessageType.Event);
            RnetDeviceId.RootController.Write(wrt);
            new RnetPath(2, 0).Write(wrt);
            new RnetPath().Write(wrt);
            wrt.WriteUInt16((ushort)RnetEvent.VolumeUp); // VOLUME UP
            wrt.WriteUInt16(0);
            wrt.WriteUInt16(0);
            wrt.WriteByte(1);
            wrt.EndMessage();

            // expected volumn up message
            var expected = new byte[] {
                0xF0,
                0x00,
                0x00,
                0x7F,
                0x00,
                0x00,
                0x70,
                0x05,
                0x02,
                0x02,
                0x00,
                0x00,
                0x7F,
                0x00,
                0x00,
                0x00,
                0x00,
                0x00,
                0x01,
                0x7B,
                0xF7,
            };

            var actual = stm.ToArray();

            Assert.IsTrue(actual.SequenceEqual(expected));
        }