コード例 #1
0
        public void TestSingleByteCalls()
        {
            FrameProtocolTester tester = new FrameProtocolTester();
            FrameProtocolFilter filter = new FrameProtocolFilter();

            filter.HandleBytes(tester, new Byte[] { 0 });
            filter.HandleBytes(tester, new Byte[] { 0 });
            filter.HandleBytes(tester, new Byte[] { 0 });
            tester.ExpectFrames(new Byte[0]);
            filter.HandleBytes(tester, new Byte[] { 0 });
            tester.AssertNoMoreExpectedFrames();

            filter.HandleBytes(tester, new Byte[] { 0 });
            filter.HandleBytes(tester, new Byte[] { 0 });
            filter.HandleBytes(tester, new Byte[] { 0 });
            filter.HandleBytes(tester, new Byte[] { 1 });
            tester.ExpectFrames(new Byte[] { 0x49 });
            filter.HandleBytes(tester, new Byte[] { 0x49 });
            tester.AssertNoMoreExpectedFrames();

            filter.HandleBytes(tester, new Byte[] { 0 });
            filter.HandleBytes(tester, new Byte[] { 0 });
            filter.HandleBytes(tester, new Byte[] { 0 });
            filter.HandleBytes(tester, new Byte[] { 2 });
            filter.HandleBytes(tester, new Byte[] { 0xE1 });
            tester.ExpectFrames(new Byte[] { 0xE1, 0xCA });
            filter.HandleBytes(tester, new Byte[] { 0xCA });
            tester.AssertNoMoreExpectedFrames();
        }
コード例 #2
0
        public void TestMultipleHandleBytesPerCommand()
        {
            FrameProtocolTester tester = new FrameProtocolTester();
            FrameProtocolFilter filter = new FrameProtocolFilter();

            filter.HandleBytes(tester, new Byte[] { 0, 0, 0, 1 });
            tester.ExpectFrames(new Byte[] { 0x72 });
            filter.HandleBytes(tester, new Byte[] { 0x72 });
            tester.AssertNoMoreExpectedFrames();

            filter.HandleBytes(tester, new Byte[] { 0, 0, 0 });
            filter.HandleBytes(tester, new Byte[] { 2 });
            filter.HandleBytes(tester, new Byte[] { 0x84 });
            tester.ExpectFrames(new Byte[] { 0x84, 0xF0 });
            filter.HandleBytes(tester, new Byte[] { 0xF0 });
            tester.AssertNoMoreExpectedFrames();

            filter.HandleBytes(tester, new Byte[] { 0 });
            filter.HandleBytes(tester, new Byte[] { 0, 0, 10 });
            filter.HandleBytes(tester, new Byte[] { 0x12, 0x34, 0x56, 0x78 });
            filter.HandleBytes(tester, new Byte[] { 0x9A, 0xBC });
            tester.ExpectFrames(new Byte[] { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0, 0x12, 0x34 });
            filter.HandleBytes(tester, new Byte[] { 0xDE, 0xF0, 0x12, 0x34 });
            tester.AssertNoMoreExpectedFrames();
        }
コード例 #3
0
        public void TestHeartbeat()
        {
            FrameProtocolTester tester = new FrameProtocolTester();
            FrameProtocolFilter filter = new FrameProtocolFilter();

            tester.ExpectFrames(new Byte[0]);
            filter.HandleBytes(tester, new Byte[] { 0, 0, 0, 0 });
            tester.AssertNoMoreExpectedFrames();

            tester.ExpectFrames(new Byte[0], new Byte[0]);
            filter.HandleBytes(tester, new Byte[] { 0, 0, 0, 0, 0, 0, 0, 0 });
            tester.AssertNoMoreExpectedFrames();
        }
コード例 #4
0
        public void TestMultipleCommandsPerHandleBytes()
        {
            FrameProtocolTester tester = new FrameProtocolTester();
            FrameProtocolFilter filter = new FrameProtocolFilter();

            tester.ExpectFrames(new Byte[0], new Byte[] { 0xA4 }, new Byte[0], new Byte[] { 0x73, 0xF3, 0x29, 0x44 }, new Byte[0]);
            filter.HandleBytes(tester, new Byte[] { 0, 0, 0, 0, 0, 0, 0, 1, 0xA4, 0, 0, 0, 0, 0, 0, 0, 4, 0x73, 0xF3, 0x29, 0x44, 0, 0, 0, 0 });
            tester.AssertNoMoreExpectedFrames();
        }
コード例 #5
0
        public void TestOverlappingHandleBytePerCommand()
        {
            FrameProtocolTester tester = new FrameProtocolTester();
            FrameProtocolFilter filter = new FrameProtocolFilter();

            tester.ExpectFrames(new Byte[0], new Byte[] { 0xA4 });
            filter.HandleBytes(tester, new Byte[] { 0, 0, 0, 0, 0, 0, 0, 1, 0xA4, 0 });
            tester.AssertNoMoreExpectedFrames();

            tester.ExpectFrames(new Byte[] { 0x73, 0xF3, 0x29, 0x44 });
            filter.HandleBytes(tester, new Byte[] { 0, 0, 4, 0x73, 0xF3, 0x29, 0x44, 0, 0 });
            tester.AssertNoMoreExpectedFrames();

            tester.ExpectFrames(new Byte[] { 0x43, 0xAB, 0x71 });
            filter.HandleBytes(tester, new Byte[] { 0, 3, 0x43, 0xAB, 0x71, 0, 0, 0, 1 });
            tester.AssertNoMoreExpectedFrames();

            tester.ExpectFrames(new Byte[] { 0xF0 }, new Byte[] { }, new Byte[] { 0x12, 0x34 }, new Byte[0]);
            filter.HandleBytes(tester, new Byte[] { 0xF0, 0, 0, 0, 0, 0, 0, 0, 2, 0x12, 0x34, 0, 0, 0, 0 });
            tester.AssertNoMoreExpectedFrames();
        }