public void NumCells_StoresCorrectly()
 {
     _sut = new GameGridService
     {
         NumCells = 3
     };
     Assert.Equal(3, _sut.NumCells);
 }
        public void Given_When_I_Call_GetBoardValue_With_Negative_Values_Then_True_An_Exception_Is_Thrown()
        {
            //arrange
            _sut = new GameGridService();

            // act and assert
            Assert.Throws<System.IndexOutOfRangeException>(() => _sut.GetBoardValue(-2, -2));
        }
Exemple #3
0
        static void Main()
        {
            Application.SetHighDpiMode(HighDpiMode.SystemAware);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            IGameGridService gameGrid = new GameGridService();

            Application.Run(new Form1(gameGrid));
        }
        public void Given_When_I_Call_GetBoardValue_With_Positive_Values_Then_True_Is_Returned(int row, int col)
        {
            //arrange and act
            var result = _sut = new GameGridService();
            var boardValue = result.GetBoardValue(row, col);

            //assert
            Assert.NotNull(result);
            Assert.True(boardValue);
        }
        public void Given_I_Call_GameGridService_Then_The_Correct_Methods_Are_Called_To_Start_A_New_Game()
        {
            //arrange

            //act
            _sut = new GameGridService();

            //assert
            _gameGrid.Verify(v => v.StartNewGame(), Times.Once);
        }
        public void Given_When_I_Call_StartNewGame_Then_The_A_GameGrid_with_5_cells_Is_SetUp()
        {
            //act
            var result = _sut = new GameGridService();

            //assert
            _sut.StartNewGame();

            Assert.NotNull(result);
            Assert.Equal(5, result.NumCells);
        }
        public void Given_When_I_Call_GameWon_With_default_Grid_The_Game_Is_Not_Won()
        {
            //arrange

            _sut = new GameGridService();

            // act and assert
            bool gameWon = _sut.GameWon();

            Assert.False(gameWon);
        }
Exemple #8
0
        /// <summary>
        /// Checks the user has set a new complexity.
        /// </summary>
        /// <returns>
        /// True if new complexity is set, false otherwise. A new game grid
        /// is generated and the visual playing field is reset.
        /// </returns>
        private bool ReevalGameComplexity()
        {
            var complexity = NewGameCmplx_Combo.SelectedItem as GameDifficultyDefinition;

            if (complexity != prevGameComplexity)
            {
                prevGameComplexity = complexity;
                game = new GameGridService(complexity.Rows, complexity.Columns, complexity.Bombs);
                ClearPlayingField();
                RestorePlayingField();
                return(true);
            }
            return(false);
        }
Exemple #9
0
        /// <summary>
        /// TODO: Move into Models or Repository
        /// </summary>
        private void InitialiseComplexityOptions()
        {
            int defaultComplexity = GameDifficultyDefinition.DefaultOptionIndex;

            var difficulties = GameDifficultyDefinition.DifficultyOptions();

            foreach (var option in difficulties)
            {
                complexityOptions.Add(option);
            }

            prevGameComplexity = complexityOptions[defaultComplexity];
            game = new GameGridService(prevGameComplexity.Rows, prevGameComplexity.Columns, prevGameComplexity.Bombs);
            NewGameCmplx_Combo.SelectedIndex = defaultComplexity;
        }
        public void Given_When_I_Call_GameWon_With_A_Winning_Grid_The_Game_Is_Won()
        {
            //arrange
            bool[,] _grid;
            _grid = new bool[5, 5]; //Create Grid
            _grid[0, 0] = false;
            _grid[0, 1] = false;

            _gameGrid = new Mock<IGameGridService>();
            _gameGrid.Setup(b => b.NumCells).Returns(It.IsAny<int>());

            var result = _sut = new GameGridService();

            // act and assert
            //TO DO
        }