Exemplo n.º 1
0
        public void Create()
        {
            // Arrange
            GamesController controller = new GamesController(repository);

            // Act
            Guid newGameId = Guid.NewGuid();
            Guid newBlackGamer = Guid.NewGuid();
            Guid newWhiteGamer = Guid.NewGuid();
            controller.Post(new GameState() { GameId = newGameId, BlackGamer = newBlackGamer, WhiteGamer = newWhiteGamer });
            GameState game = controller.Get(newGameId);

            // Assert
            Assert.AreEqual("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", game.GameStateNotation);
            Assert.AreEqual(newGameId, game.GameId);
            Assert.AreEqual(newBlackGamer, game.BlackGamer);
            Assert.AreEqual(newWhiteGamer, game.WhiteGamer);
        }
Exemplo n.º 2
0
        public void GameUpdate()
        {
            GameMove move = new GameMove() { MoveNotation = "a2 a4" };
            // Arrange
            GamesController controller = new GamesController(repository);

            // Act
            GameState updatedGame = controller.Get(gameId);
            List<GameMove> moves = new List<GameMove>(updatedGame.Moves);
            moves.Add(move);
            updatedGame.Moves = moves;
            controller.Put(updatedGame);
            updatedGame = controller.Get(gameId);

            // Assert
            GameState game = new GameState();
            game.RegisterMove(move);
            Assert.AreEqual(game.GameStateNotation, updatedGame.GameStateNotation);
        }
Exemplo n.º 3
0
        public void Get()
        {
            // Arrange
            GamesController controller = new GamesController(repository);

            // Act
            IEnumerable<GameState> result = controller.Get();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Count());
            Assert.AreEqual("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", result.ElementAt(0).GameStateNotation);
        }
Exemplo n.º 4
0
        public void GetById()
        {
            // Arrange
            GamesController controller = new GamesController(repository);

            // Act
            GameState result = controller.Get(gameId);

            // Assert
            Assert.AreEqual("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", result.GameStateNotation);
        }