public void TestCase() { byte[] buffer = new byte[100]; { MessageBuilder builder = new MessageBuilder(buffer, 0); builder.Add(15, 6512); Assert.AreEqual(3, builder.GetPosition()); } Assert.AreEqual(120, buffer[0]); Assert.AreEqual((byte)177, buffer[1]); Assert.AreEqual(112, buffer[2]); { MessageParser parser = new MessageParser(buffer, 0, 3); Assert.AreEqual(MessageParser.State.FoundTag, parser.Next()); Assert.AreEqual(15, parser.GetTag()); Assert.AreEqual(6512, parser.GetInt()); Assert.AreEqual(MessageParser.State.EndOfDocument, parser.Next()); } { MessageBuilder builder = new MessageBuilder(buffer, 0); builder.Add(129, 6512); Assert.AreEqual(5, builder.GetPosition()); } Assert.AreEqual((byte)248, buffer[0]); Assert.AreEqual((byte)128, buffer[1]); Assert.AreEqual(1, buffer[2]); Assert.AreEqual((byte)177, buffer[3]); Assert.AreEqual((byte)112, buffer[4]); { MessageParser parser = new MessageParser(buffer, 0, 5); Assert.AreEqual(MessageParser.State.FoundTag, parser.Next()); Assert.AreEqual(129, parser.GetTag()); Assert.AreEqual(6512, parser.GetInt()); Assert.AreEqual(MessageParser.State.EndOfDocument, parser.Next()); } }