public void TestReadStringTruncated() { byte[] data = { 0x07, 0x00, 0x00, 0x00, Convert.ToByte('H'), Convert.ToByte('e'), Convert.ToByte('l'), Convert.ToByte('l'), Convert.ToByte('o'), 0x00 }; using (Parser parser = new Parser()) { parser.Load("Tests", data); parser.ReadStr(); } }
public void TestReadStringMultiple() { byte[] data = { 0x06, 0x00, 0x00, 0x00, Convert.ToByte('H'), Convert.ToByte('e'), Convert.ToByte('l'), Convert.ToByte('l'), Convert.ToByte('o'), 0x00, 0x07, 0x00, 0x00, 0x00, Convert.ToByte('W'), Convert.ToByte('o'), Convert.ToByte('r'), Convert.ToByte('l'), Convert.ToByte('d'), Convert.ToByte('!'), 0x00 }; using (Parser parser = new Parser()) { parser.Load("Tests", data); string result1 = parser.ReadStr(); Assert.AreEqual("Hello", result1, string.Format("First Part did not match: Expected: {0}, Actual: {1}", "Hello", result1)); string result2 = parser.ReadStr(); Assert.AreEqual("World!", result2, string.Format("Second Part did not match: Expected: {0}, Actual: {1}", "World!", result2)); } }
public void TestReadNull() { byte[] data = { 0x00, 0x00, 0x00, 0x00 }; using (Parser parser = new Parser()) { parser.Load("Tests", data); string result = parser.ReadStr(); Assert.AreEqual("", result, string.Format("Read String did not match: Expected: {0}, Actual: {1}", "", result)); } }
public void TestReadString() { byte[] data = { 0x06, 0x00, 0x00, 0x00, Convert.ToByte('H'), Convert.ToByte('e'), Convert.ToByte('l'), Convert.ToByte('l'), Convert.ToByte('o'), 0x00 }; using (Parser parser = new Parser()) { parser.Load("Tests", data); string result = parser.ReadStr(); Assert.AreEqual("Hello", result, string.Format("Read String did not match: Expected: {0}, Actual: {1}", "Hello", result)); } }
public void TestReadIncorrectSize() { byte[] data = { 0x04, 0x00, 0x00, 0x00, Convert.ToByte('H'), Convert.ToByte('e'), Convert.ToByte('l'), Convert.ToByte('l'), Convert.ToByte('o'), 0x00 }; using (Parser parser = new Parser()) { parser.Load("Tests", data); parser.ReadStr(); } }