Esempio n. 1
0
        public void addRandomValueTest()
        {
            GridBlock g1 = new GridBlock(3);

            // Test: initial counters
            Assert.AreEqual(g1.NumberOfElements, 9);
            Assert.AreEqual(g1.countAssignedPositions(), 0);
            Assert.AreEqual(g1.countUnassignedPositions(), 9);

            // Test: 1 add
            g1.addRandomValue();

            Assert.AreEqual(g1.NumberOfElements, 9);
            Assert.AreEqual(g1.countAssignedPositions(), 1);
            Assert.AreEqual(g1.countUnassignedPositions(), 8);

            // Test: maximum adds
            g1.addRandomValue();
            g1.addRandomValue();
            g1.addRandomValue();
            g1.addRandomValue();
            g1.addRandomValue();
            g1.addRandomValue();
            g1.addRandomValue();
            g1.addRandomValue();
            g1.addRandomValue();
            g1.addRandomValue();
            g1.addRandomValue();

            Assert.AreEqual(g1.NumberOfElements, 9);
            Assert.AreEqual(g1.countAssignedPositions(), 9);
            Assert.AreEqual(g1.countUnassignedPositions(), 0);
        }
Esempio n. 2
0
        public void countUnassignedPositionsTest()
        {
            GridBlock g1 = new GridBlock(3);

            Assert.AreEqual(g1.countUnassignedPositions(), 9);

            g1.setValueAtPosition(0, 1);
            g1.setValueAtPosition(1, 2);

            Assert.AreEqual(g1.countUnassignedPositions(), 7);
        }
Esempio n. 3
0
        public void fillGridBlockEntirelyTest()
        {
            // test: initial GridBlock
            GridBlock g1 = new GridBlock(3);
            Assert.AreEqual(g1.countAssignedPositions(), 0);
            Assert.AreEqual(g1.countUnassignedPositions(), 9);
            g1.fillGridBlockEntirely();
            Assert.AreEqual(g1.countAssignedPositions(), 9);
            Assert.AreEqual(g1.countUnassignedPositions(), 0);

            // test: GridBlock with some assigned values
            GridBlock g2 = new GridBlock(3);
            g2.setValueAtPosition(0, 5);
            g2.addRandomValue();
            Assert.AreEqual(g2.countAssignedPositions(), 2);
            Assert.AreEqual(g2.countUnassignedPositions(), 7);
            g2.fillGridBlockEntirely();
            Assert.AreEqual(g2.countAssignedPositions(), 9);
            Assert.AreEqual(g2.countUnassignedPositions(), 0);
        }