Exemplo n.º 1
0
        public void ShouldProvideABoardToPlayTheGame()
        {
            board = new Board(9);
            var moqBoardGenerator = createMock();
            var controller = new GameController(moqBoardGenerator.Object);
            var result = controller.Index() as ViewResult;

            Assert.IsNotNull(result.Model);
            moqBoardGenerator.Verify();
        }
Exemplo n.º 2
0
        public void ShouldReturnFalseWhenDoesntHaveBomb()
        {
            var moqBoardGenerator = createMock();
            var controller = new GameController(moqBoardGenerator.Object);
            int row = 1;
            int col = 2;
            board = new Board(9);
            var session = new SessionStateItemCollection();
            session["board"] = board;
            controller.ControllerContext = new FakeControllerContext(controller, session);

            var result = controller.HasBomb(row, col);
            Assert.IsFalse((bool)result.Data);
        }
Exemplo n.º 3
0
        public void ShouldReturnTrueWhenCellHasBomb()
        {
            var session = new SessionStateItemCollection();
            board = new Board(9);
            board.AddBombAt(1, 2);
            session["board"] = board;

            var moqBoardGenerator = createMock();
            var controller = new GameController(moqBoardGenerator.Object);
            controller.ControllerContext = new FakeControllerContext(controller, session);
            int row = 1;
            int col = 2;

            JsonResult result = controller.HasBomb(row, col);
            Assert.IsTrue((bool)result.Data);
        }