Пример #1
0
        public void CheckIfGetGameStateReturnsATie()
        {
            var board = new Board(3);

            board.UpdateSquare(new Coordinate {
                X = 0, Y = 0
            }, 'O');
            board.UpdateSquare(new Coordinate {
                X = 1, Y = 0
            }, 'X');
            board.UpdateSquare(new Coordinate {
                X = 2, Y = 0
            }, 'X');
            board.UpdateSquare(new Coordinate {
                X = 0, Y = 1
            }, 'X');
            board.UpdateSquare(new Coordinate {
                X = 1, Y = 1
            }, 'X');
            board.UpdateSquare(new Coordinate {
                X = 2, Y = 1
            }, 'O');
            board.UpdateSquare(new Coordinate {
                X = 0, Y = 2
            }, 'O');
            board.UpdateSquare(new Coordinate {
                X = 1, Y = 2
            }, 'O');
            board.UpdateSquare(new Coordinate {
                X = 2, Y = 2
            }, 'X');

            var winDecider = new WinDecider();
            var actual     = winDecider.GetGameState(board);
            var expected   = GameState.Tie;

            Assert.Equal(expected, actual);
        }
Пример #2
0
        public void CheckIfGetGameStateReturnsLeftDiagonalWin()
        {
            var board  = new Board(3);
            var coord1 = new Coordinate {
                X = 2, Y = 0
            };
            var coord2 = new Coordinate {
                X = 1, Y = 1
            };
            var coord3 = new Coordinate {
                X = 0, Y = 2
            };

            board.UpdateSquare(coord1, 'X');
            board.UpdateSquare(coord2, 'X');
            board.UpdateSquare(coord3, 'X');

            var winDecider = new WinDecider();
            var actual     = winDecider.GetGameState(board);
            var expected   = GameState.DiagonalWin;

            Assert.Equal(expected, actual);
        }