Example #1
0
 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();
     }
 }
Example #2
0
 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));
     }
 }
Example #3
0
 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));
     }
 }
Example #4
0
 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));
     }
 }
Example #5
0
 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();
     }
 }