Esempio n. 1
0
        public void TestGetValues()
        {
            int size = 52;
            PointTable table = new PointTable(size);
            byte[] bs = table.GetValues(0, 0, 3);
            Assert.AreEqual(1, bs.Length);
            Assert.AreEqual(0, bs[0]);

            table.SetValueAt(0, 1, true);
            bs = table.GetValues(0, 0, 3);
            Assert.AreEqual(2, bs[0]); // 0b...010" = 2;

            table.SetValueAt(0, 2, true);
            bs = table.GetValues(0, 0, 3); // 110=6;
            Assert.AreEqual(6, bs[0]);

            bs = table.GetValues(0, 0, 8); // 00000110=6;
            Assert.AreEqual(6, bs[0]);

            table.SetValueAt(0, 8, true);
            bs = table.GetValues(0, 0, 9); // 00000001,00000110=6;
            Assert.AreEqual(6, bs[0]);
            Assert.AreEqual(1, bs[1]);
        }
Esempio n. 2
0
        public void TestPointTable()
        {
            int size = 52;
            PointTable table = new PointTable(size);
            table.SetValueAt(1, 0, true);
            Assert.AreEqual(1, table.GetValueAt(1, 0));
            Assert.AreEqual(PointTable.INVALID_COIL_VAL, table.GetValueAt(size, 0));
            Assert.AreEqual(0, table.GetValueAt(CMS.REG_CNT -1, 0));

            // Set All
            table.Fill(true);
            for (int i = 0; i < size; i++)
                for (int j = 0; j < 16; j++)
                    Assert.AreEqual(1, table.GetValueAt(i,j));

            // Reset All
            table.Fill(false);
            for (int i = 0; i < 52; i++)
                for (int j = 0; j < 8; j++)
                    Assert.AreEqual(0, table.GetValueAt(i, j));
        }