Ejemplo n.º 1
0
        public void MinesweeperTest_LosesGame()
        {
            Grid testGrid = new Grid(_GridOps.Object);
            int turn = 0;
            int[] valuePoints = { 4, 2, 1, 1 };
            var valueQueue = new Queue<int>();
            foreach (var i in valuePoints)
            {
                valueQueue.Enqueue(i);
            }
            _GridOps.Setup(x => x.ReadInputNumber()).Returns(valueQueue.Dequeue);

            bool finish;
            do
            {
                turn++;
                finish = testGrid.CheckCellPosition(turn);
                if (!finish)
                {
                    testGrid.RevealNeighbors();
                    finish = testGrid.Win();
                }
            }
            while (!finish);
            Assert.IsFalse(testGrid.Win());
        }
Ejemplo n.º 2
0
        public void GridTest_RowAndColumnRepeated()
        {
            Grid testGrid = new Grid(_GridIO.Object);
            int turn = 0;
            int[] valuePoints = { 4, 2, 4, 2, 1, 1 };
            var valueQueue = new Queue<int>();
            foreach (var i in valuePoints)
            {
                valueQueue.Enqueue(i);
            }
            _GridIO.Setup(x => x.ReadInputNumber()).Returns(valueQueue.Dequeue);

            bool finish;
            do
            {
                turn++;
                finish = testGrid.CheckCellPosition(turn);
                if (!finish)
                {
                    testGrid.RevealNeighbors();
                    finish = testGrid.Win();
                }
            }
            while (!finish);
            Assert.AreSame("Field already shown", _Message);
        }