public void TestParsePayloadThatIsNotAtheStartOfTheBuffer()
        {
            PayloadParser parser = new PayloadParser();
            parser.AppendData(new byte[] { 0x00 });
            parser.AppendData(ValidPayloads.payloadWithTitlePingAndTextValueHello);
            Payload payload = parser.FindAndRemoveNextPayload();

            Assert.AreEqual("ping", payload.Title);
            CollectionAssert.AreEqual(new byte[] { 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x00 }, payload.Value);
        }
        public void TestParseBufferContainginTwoPayloads()
        {
            PayloadParser parser = new PayloadParser();
            parser.AppendData(ValidPayloads.payloadWithTitlePingAndTextValueHello);
            parser.AppendData(ValidPayloads.payloadWithTitlePingAndEmptyTextValue);

            Payload payload = parser.FindAndRemoveNextPayload();
            Assert.AreEqual("ping", payload.Title);
            CollectionAssert.AreEqual(new byte[] { 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x00 }, payload.Value);

            payload = parser.FindAndRemoveNextPayload();
            Assert.AreEqual("ping", payload.Title);
            CollectionAssert.AreEqual(new byte[] { 0x00 }, payload.Value);

            payload = parser.FindAndRemoveNextPayload();
            Assert.AreEqual(null, payload);
        }
        public void TestParsePayloadWithEmptyTextValue()
        {
            PayloadParser parser = new PayloadParser();
            parser.AppendData(ValidPayloads.payloadWithTitlePingAndEmptyTextValue);
            Payload payload = parser.FindAndRemoveNextPayload();

            Assert.AreEqual("ping", payload.Title);
            CollectionAssert.AreEqual(new byte[] { 0x00 }, payload.Value);
        }
        public void TestParsePayloadWithMissingFirstTwoBytes()
        {
            PayloadParser parser = new PayloadParser();
            parser.AppendData(InvalidPayloads.payloadWithMissingFirstByte);
            Payload payload = parser.FindAndRemoveNextPayload();

            Assert.AreEqual(null, payload);
        }
        public void TestParsePayloadWithMissingFirstByteAndAddedOtherByte()
        {
            PayloadParser parser = new PayloadParser();
            parser.AppendData(new byte[] { 0x00 });
            parser.AppendData(InvalidPayloads.payloadWithMissingFirstByte);
            Payload payload = parser.FindAndRemoveNextPayload();

            Assert.AreEqual(null, payload);
        }
        public void TestParsePayloadWithEmptyTitle()
        {
            PayloadParser parser = new PayloadParser();
            parser.AppendData(ValidPayloads.payloadWithEmptyTitleAndTextValueHello);
            Payload payload = parser.FindAndRemoveNextPayload();

            Assert.AreEqual("", payload.Title);
            CollectionAssert.AreEqual(new byte[] { 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x00 }, payload.Value);
        }