Beispiel #1
0
        public void updateAdjTest()
        {
            String     neighbor    = "1";
            Coordinate checker     = new Coordinate(0, 0);
            EditorForm testEditor1 = new EditorForm(5, 5);
            Button     sender      = new Button();

            testEditor1.Form3_Load(sender, null);
            testEditor1.map.squares[checker].isBomb = !testEditor1.map.squares[checker].isBomb;
            testEditor1.updateAdj();
            //checking to see if bombs are there after "click"
            Assert.IsNotNull(testEditor1.buttons[0, 0].BackgroundImage);
            Coordinate[] adjCheck = { new Coordinate(0, 1), new Coordinate(1, 1), new Coordinate(1, 0) };
            //checking the appended numbers next to bomb
            foreach (Coordinate c in adjCheck)
            {
                Assert.AreEqual(neighbor, testEditor1.buttons[c.x, c.y].Text);
            }
        }
Beispiel #2
0
        public void MapClickedTest()
        {
            // check an empty space can be clicked and if it's a bomb
            bool       bomb        = true;
            Coordinate checker     = new Coordinate(0, 0);
            EditorForm testEditor1 = new EditorForm(5, 5);
            Button     sender      = new Button();

            testEditor1.Form3_Load(sender, null);

            testEditor1.MapClicked(testEditor1.buttons[0, 0], null);

            Assert.AreEqual(checker, testEditor1.check);
            Assert.AreEqual(bomb, testEditor1.map.squares[checker].isBomb);
            //check a filled space can be clicked and now not a bomb
            testEditor1.MapClicked(testEditor1.buttons[0, 0], null);
            bomb = false;
            Assert.AreEqual(checker, testEditor1.check);
            Assert.AreEqual(bomb, testEditor1.map.squares[checker].isBomb);
        }