public InteractiveSqlApplicationTests()
 {
     var sqlExecutor = new SqlExecutor(SqlServerConfiguration.ReadAppSettings());
     var hintGenerator = new HintGenerator();
     m_Application = new InteractiveSqlApplication(m_Logger, sqlExecutor, hintGenerator, CreateCourse());
     m_Application.Start();
 }
示例#2
0
 public IEnumerable <string> GenerateHints(string hintKeys, int quantity)
 {
     if (hintKeys.Contains('|'))
     {
         return(AlternateHintGenerator.Generate(hintKeys, quantity));
     }
     return(HintGenerator.Generate(hintKeys, quantity));
 }
        public void Test_Persistance()
        {
            HintGenerator hints = new HintGenerator(5, 5, framework.GetSolution(5, 5));
            List <Hint>   listA = hints.TestGenerateHintList();

            Debug_HintList.RemoveAHint(new List <Hint> (listA));
            Assert.AreEqual(CalculateHintNumber(5, 5), listA.Count);
        }
 public void HintGeneratorTest1()
 {
     Enumerable.Range(1, 200).ToList().ForEach(amount =>
     {
         var result = HintGenerator.Generate("asdfhjkl", amount);
         Assert.AreEqual(amount, result.Count());
         Assert.IsFalse(result.Any(x => result.Any(y => y.StartsWith(x) && y != x)));
     });
 }
示例#5
0
        public void ToStringShould_ReturnExpectedString_WhenThereIsNoMinesInASize2Board()
        {
            const string expectedString = ". . \n" + ". . \n";
            var          board          = Board.CreateEmptyBoard(2);
            var          minesGenerator = new RandomMinesGenerator();

            minesGenerator.PlaceMines(0, board);
            HintGenerator.SetHints(board);
            Assert.Equal(expectedString, board.ToString());
        }
示例#6
0
        public void ToStringShould_ReturnExpectedString_WhenThereIs1RevealedTopLeftMineInASize2Board()
        {
            var          mineGenerator  = new MockMinesGenerator();
            const string expectedString = "* 1 \n" + "1 1 \n";
            var          board          = Board.CreateEmptyBoard(2);

            mineGenerator.PlaceMines(1, board);
            HintGenerator.SetHints(board);
            board.RevealAllSquares();
            Assert.Equal(expectedString, board.ToString());
        }
示例#7
0
        public void ToStringShould_ReturnExpectedString_WhenThereIs1RevealedMineInASize1Board()
        {
            const string expectedHiddenString   = ". \n";
            const string expectedRevealedString = "* \n";
            var          board          = Board.CreateEmptyBoard(1);
            var          minesGenerator = new RandomMinesGenerator();

            minesGenerator.PlaceMines(1, board);
            HintGenerator.SetHints(board);
            Assert.Equal(expectedHiddenString, board.ToString());
            board.RevealAllSquares();
            Assert.Equal(expectedRevealedString, board.ToString());
        }
示例#8
0
        public void CreateBoard()
        {
            var difficultyValue = SetDifficultyValue();
            var size            = difficultyValue;

            Board = Board.CreateEmptyBoard(size);
            var numberOfMines = difficultyValue;

            _minesGenerator.PlaceMines(numberOfMines, Board);
            HintGenerator.SetHints(Board);
            _output.Write(GameInstruction.DisplayCurrentBoardMessage);
            DisplayBoard();
        }
        public void SetHintsShould_setHintTo0_WhenThereIsOnly1MineSquare()
        {
            var mineGenerator = new RandomMinesGenerator();
            var board         = Board.CreateEmptyBoard(1);

            mineGenerator.PlaceMines(1, board);

            HintGenerator.SetHints(board);
            foreach (var item in board.Squares)
            {
                Assert.Equal(0, item.Hint);
            }
        }
示例#10
0
        public void SetHintsShould_Set3HintsWithValue1_WhenThereIs1Mine_InASize2Board()
        {
            var board         = Board.CreateEmptyBoard(2);
            var mineGenerator = new RandomMinesGenerator();

            mineGenerator.PlaceMines(1, board);

            HintGenerator.SetHints(board);

            var squaresWithHintValueOne = board.Squares.Where(item => item.Hint == 1);

            Assert.Equal(3, squaresWithHintValueOne.Count());
        }
示例#11
0
    public void BuildHints(int _cols, int _rows, float _totemSpacing, int[] _solution)
    {
        cols = _cols;
        rows = _rows;
        //totemSpacing = _totemSpacing;
        solution = _solution;

        hintList = new List <Hint> ();
        CreateBackground();
        HintGenerator hints = new HintGenerator(cols, rows, solution);

        hintList = hints.GetPrunedHintList();
    }
示例#12
0
        public void SetHintsShould_Set8HintsWithValue1_WhenThereIs1Mine_InTheMiddleOfASize3Board()
        {
            var board          = Board.CreateEmptyBoard(3);
            var centerLocation = new Location(1, 1);
            var square         = board.GetSquare(centerLocation);

            square.SetMine();

            HintGenerator.SetHints(board);

            var squaresWithHintValueOne = board.Squares.Where(item => item.Hint == 1);

            Assert.Equal(8, squaresWithHintValueOne.Count());
        }
示例#13
0
    public void Test_3x4()
    {
        solution = framework.GetSolution(3, 4);

        HintGenerator hg = new HintGenerator(3, 4, solution);

        hintList = hg.TestGenerateHintList();

        foreach (Hint hint in hintList)
        {
            UnityEngine.Debug.Log(hint.ToString());
        }

        Assert.True(true);
    }
示例#14
0
        public void SetHintsShould_Set3HintsWithValue1_WhenThereIs1Mine_InTheTopLeftCornerOfASize3Board()
        {
            var board   = Board.CreateEmptyBoard(3);
            var topLeft = new Location(0, 0);
            var square  = board.GetSquare(topLeft);

            square.SetMine();

            HintGenerator.SetHints(board);

            var squaresWithHintValueOne  = board.Squares.Where(item => item.Hint == 1);
            var squaresWithHintValueZero = board.Squares.Where(item => item.Hint == 0);

            Assert.Equal(3, squaresWithHintValueOne.Count());
            Assert.Equal(6, squaresWithHintValueZero.Count());
        }
示例#15
0
        public void GivenASquarePositionInABoard_ReturnNumberOfMinesFromNeighbourSquares(Position squarePosition, int expected)
        {
            var width         = 3;
            var height        = 3;
            var leftTop       = new Position(0, 0);
            var middleTop     = new Position(0, 1);
            var minePositions = new List <Position> {
                leftTop,
                middleTop
            };
            var board = new Board(width, height, minePositions);

            var actual = HintGenerator.GetNumberOfMinesFromNeighbourSquares(board, squarePosition);

            Assert.Equal(expected, actual);
        }
示例#16
0
        public void SetHintsShould_Set2HintsWithValue2_WhenThereAre2Mines_InTheTopLineOfASize2Board()
        {
            var board         = Board.CreateEmptyBoard(2);
            var topLeft       = new Location(0, 0);
            var topLeftSquare = board.GetSquare(topLeft);

            topLeftSquare.SetMine();
            var topRight       = new Location(0, 1);
            var topRightSquare = board.GetSquare(topRight);

            topRightSquare.SetMine();

            HintGenerator.SetHints(board);

            var squaresWithHintValueTwo = board.Squares.Where(item => item.Hint == 2);

            Assert.Equal(2, squaresWithHintValueTwo.Count());
        }
        public void Test_3x3HintList()
        {
            HintGenerator hints = new HintGenerator(3, 3, framework.GetSolution(3, 3));

            Assert.AreEqual(CalculateHintNumber(3, 3), hints.TestGenerateHintList().Count);                // 33
        }
        public void Test_5x4HintList()
        {
            HintGenerator hints = new HintGenerator(5, 4, framework.GetSolution(5, 4));

            Assert.AreEqual(CalculateHintNumber(5, 4), hints.TestGenerateHintList().Count);
        }