Beispiel #1
0
 public void TestReadIntMultiple()
 {
     byte[] data = { 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 };
     using (Parser parser = new Parser())
     {
         parser.Load("Tests", data);
         int result1 = parser.ReadInt();
         Assert.AreEqual(0, result1,
             string.Format("Read Int did not match: Expected: {0}, Actual: {1}", "0", result1));
         int result2 = parser.ReadInt();
         Assert.AreEqual(1, result2,
             string.Format("Read Int did not match: Expected: {0}, Actual: {1}", "1", result2));
     }
 }
Beispiel #2
0
        public void TestReadInt()
        {
            Dictionary<byte[], int> testCases = new Dictionary<byte[], int>
            {
                {new byte[] {0x00,0x00,0x00,0x00}, 0},
                {new byte[] {0x01,0x00,0x00,0x00}, 1},
                {new byte[] {0xff,0xff,0xff,0xff}, -1}
            };
            using (Parser parser = new Parser())
            {
                foreach (KeyValuePair<byte[], int> entry in testCases)
                {

                    parser.Load("Tests", entry.Key);
                    int result = parser.ReadInt();
                    Assert.AreEqual(entry.Value, result,
                        string.Format("Read Int did not match: Expected: {0}, Actual: {1}", entry.Value, result));
                }
            }
        }