Пример #1
0
        public MainWindow()
        {
            InitializeComponent();

            board = new GameBoard();
            bot = new PlayerBot(board);
            bot.ChooseBoardElement(new Random());

            GameBoardControl.Data = board;
        }
Пример #2
0
        public void AskLocation_NoMatches_ReturnFalse()
        {
            // Setup
            var board = new GameBoard();

            var bot = new PlayerBot(board);
            bot.ChooseBoardElement(new Random(1));

            // Call
            var answer = bot.AskLocation(0, 0);

            // Assert
            Assert.IsFalse(answer);
        }
Пример #3
0
        public void AskLocation_InvalidIndexes_ThrowArgumentOutOfRangeException(
            int horizontal, int vertical)
        {
            // Setup
            var board = new GameBoard();

            var bot = new PlayerBot(board);
            bot.ChooseBoardElement(new Random());

            // Call
            TestDelegate call = () => bot.AskLocation(horizontal, vertical);

            // Assert
            Assert.Throws<ArgumentOutOfRangeException>(call);
        }
Пример #4
0
        public void AskLocation_AtLocation_ReturnTrue()
        {
            // Setup
            var seed = 2;
            var inputRandom = new Random(seed);
            var referenceRandom = new Random(seed);
            var board = new GameBoard();

            var bot = new PlayerBot(board);
            bot.ChooseBoardElement(inputRandom);

            // Call
            var locationIndex = referenceRandom.Next(0, board.Size);
            var location2Index = referenceRandom.Next(0, board.Size);
            var answer = bot.AskLocation(locationIndex, location2Index);

            // Assert
            Assert.IsTrue(answer);
        }
Пример #5
0
        public void AskLocation_ElementWithSameSecondaryElementValue_ReturnTrue()
        {
            // Setup
            var seed = 2;
            var inputRandom = new Random(seed);
            var referenceRandom = new Random(seed);
            var board = new GameBoard();

            var locationIndex = referenceRandom.Next(0, board.Size);
            var location2Index = referenceRandom.Next(0, board.Size);
            var expectedChosenElement = board.Elements[locationIndex, location2Index];

            int inputRowIndex = -1, intputColumnIndex = -1;
            for (int i = 0; i < board.Size; i++)
            {
                for (int j = 0; j < board.Size; j++)
                {
                    if (expectedChosenElement.SecondaryElementValue == board.Elements[i, j].SecondaryElementValue)
                    {
                        inputRowIndex = i;
                        intputColumnIndex = j;
                    }
                }
            }

            var bot = new PlayerBot(board);
            bot.ChooseBoardElement(inputRandom);

            // Call

            var answer = bot.AskLocation(inputRowIndex, intputColumnIndex);

            // Assert
            Assert.IsTrue(answer);
        }