# File test/game-test.rb, line 365
  def test_game
    game = Game.new(6,6,6,6,6)

    pieceA1 = game.pieces['a1']
    pieceA2 = game.pieces['a2']
    pieceB2 = game.pieces['b2']

    posA  = game.board.positions['a']
    posB  = game.board.positions['b']
    posA3 = game.board.positions['a3']
    posA4 = game.board.positions['a4']
    posA5 = game.board.positions['a5']

    moveA2A  = Move.new(pieceA2, posA , true)
    moveA1A3 = Move.new(pieceA1, posA3)
    moveA1A5 = Move.new(pieceA1, posA5)
    moveA2A4 = Move.new(pieceA2, posA4)
    moveA2A3 = Move.new(pieceA2, posA3)
    moveB2A5 = Move.new(pieceB2, posA5)
    moveB2A3 = Move.new(pieceB2, posA3)
    moveB2A4 = Move.new(pieceB2, posA4)

    assert_equal [], game.history
    assert_equal game.pieces['a1'].position, game.board.positions['a']
    assert_equal game.pieces['a1'].captured, false
    assert_equal game.pieces['a1'].contains, []
    assert_equal game.pieces['a2'].position, game.board.positions['a']
    assert_equal game.pieces['a2'].captured, false
    assert_equal game.pieces['a2'].contains, []
    assert_equal game.pieces['b2'].position, game.board.positions['b']
    assert_equal game.pieces['b2'].captured, false
    assert_equal game.pieces['b2'].contains, []

    game.apply_move(moveA1A5, 'a')
    assert_equal game.history.length, 1
    assert_equal game.pieces['a1'].position, game.board.positions['a5']
    assert_equal game.pieces['a1'].captured, false
    assert_equal game.pieces['a1'].contains, []
    assert_equal game.pieces['a2'].position, game.board.positions['a']
    assert_equal game.pieces['a2'].captured, false
    assert_equal game.pieces['a2'].contains, []
    assert_equal game.pieces['b2'].position, game.board.positions['b']
    assert_equal game.pieces['b2'].captured, false
    assert_equal game.pieces['b2'].contains, []

    game.apply_move(moveB2A3, 'b')
    assert_equal game.history.length, 2
    assert_equal game.pieces['a1'].position, game.board.positions['a5']
    assert_equal game.pieces['a1'].captured, false
    assert_equal game.pieces['a1'].contains, []
    assert_equal game.pieces['a2'].position, game.board.positions['a']
    assert_equal game.pieces['a2'].captured, false
    assert_equal game.pieces['a2'].contains, []
    assert_equal game.pieces['b2'].position, game.board.positions['a3']
    assert_equal game.pieces['b2'].captured, false
    assert_equal game.pieces['b2'].contains, []

    game.apply_move(moveA2A4, 'a')
    assert_equal game.history.length, 3
    assert_equal game.pieces['a1'].position, game.board.positions['a5']
    assert_equal game.pieces['a1'].captured, false
    assert_equal game.pieces['a1'].contains, []
    assert_equal game.pieces['a2'].position, game.board.positions['a4']
    assert_equal game.pieces['a2'].captured, false
    assert_equal game.pieces['a2'].contains, []
    assert_equal game.pieces['b2'].position, game.board.positions['a3']
    assert_equal game.pieces['b2'].captured, false
    assert_equal game.pieces['b2'].contains, []

    game.apply_move(moveB2A5, 'b')
    assert_equal game.history.length, 4
    assert_equal game.pieces['a1'].position, game.board.positions['a5']
    assert_equal game.pieces['a1'].captured, true
    assert_equal game.pieces['a1'].contains, []
    assert_equal game.pieces['a2'].position, game.board.positions['a4']
    assert_equal game.pieces['a2'].captured, false
    assert_equal game.pieces['a2'].contains, []
    assert_equal game.pieces['b2'].position, game.board.positions['a5']
    assert_equal game.pieces['b2'].captured, false
    assert       game.pieces['b2'].contains.include?(pieceA1)
    assert_equal game.pieces['b2'].contains.length, 1

    assert_raise(InvalidMoveError) {game.apply_move(moveA1A3, 'a')}
    assert_equal game.history.length, 4
    assert_equal game.pieces['a1'].position, game.board.positions['a5']
    assert_equal game.pieces['a1'].captured, true
    assert_equal game.pieces['a1'].contains, []
    assert_equal game.pieces['a2'].position, game.board.positions['a4']
    assert_equal game.pieces['a2'].captured, false
    assert_equal game.pieces['a2'].contains, []
    assert_equal game.pieces['b2'].position, game.board.positions['a5']
    assert_equal game.pieces['b2'].captured, false
    assert       game.pieces['b2'].contains.include?(pieceA1)
    assert_equal game.pieces['b2'].contains.length, 1

    game.apply_move(moveA2A3, 'a')
    assert_equal game.history.length, 5
    assert_equal game.pieces['a1'].position, game.board.positions['a5']
    assert_equal game.pieces['a1'].captured, true
    assert_equal game.pieces['a1'].contains, []
    assert_equal game.pieces['a2'].position, game.board.positions['a3']
    assert_equal game.pieces['a2'].captured, false
    assert_equal game.pieces['a2'].contains, []
    assert_equal game.pieces['b2'].position, game.board.positions['a5']
    assert_equal game.pieces['b2'].captured, false
    assert       game.pieces['b2'].contains.include?(pieceA1)
    assert_equal game.pieces['b2'].contains.length, 1

    game.apply_move(moveB2A4, 'b')
    assert_equal game.history.length, 6
    assert_equal game.pieces['a1'].position, game.board.positions['a4']
    assert_equal game.pieces['a1'].captured, true
    assert_equal game.pieces['a1'].contains, []
    assert_equal game.pieces['a2'].position, game.board.positions['a3']
    assert_equal game.pieces['a2'].captured, false
    assert_equal game.pieces['a2'].contains, []
    assert_equal game.pieces['b2'].position, game.board.positions['a4']
    assert_equal game.pieces['b2'].captured, false
    assert       game.pieces['b2'].contains.include?(pieceA1)
    assert_equal game.pieces['b2'].contains.length, 1

    game.apply_move(moveA2A4, 'a')
    assert_equal game.history.length, 7
    assert_equal game.pieces['a1'].position, game.board.positions['a4']
    assert_equal game.pieces['a1'].captured, true
    assert_equal game.pieces['a1'].contains, []
    assert_equal game.pieces['a2'].position, game.board.positions['a4']
    assert_equal game.pieces['a2'].captured, false
    assert_equal game.pieces['a2'].contains, []
    assert_equal game.pieces['b2'].position, game.board.positions['a4']
    assert_equal game.pieces['b2'].captured, false
    assert       game.pieces['b2'].contains.include?(pieceA1)
    assert_equal game.pieces['b2'].contains.length, 1

    game.apply_move(moveB2A3, 'b')
    assert_equal game.history.length, 8
    assert_equal game.pieces['a1'].position, game.board.positions['a3']
    assert_equal game.pieces['a1'].captured, true
    assert_equal game.pieces['a1'].contains, []
    assert_equal game.pieces['a2'].position, game.board.positions['a4']
    assert_equal game.pieces['a2'].captured, false
    assert_equal game.pieces['a2'].contains, []
    assert_equal game.pieces['b2'].position, game.board.positions['a3']
    assert_equal game.pieces['b2'].captured, false
    assert       game.pieces['b2'].contains.include?(pieceA1)
    assert_equal game.pieces['b2'].contains.length, 1

    game.apply_move(moveA2A3, 'a')
    assert_equal game.history.length, 9
    assert_equal game.pieces['a1'].position, game.board.positions['a3']
    assert_equal game.pieces['a1'].captured, true
    assert_equal game.pieces['a1'].contains, []
    assert_equal game.pieces['a2'].position, game.board.positions['a3']
    assert_equal game.pieces['a2'].captured, false
    assert       game.pieces['a2'].contains.include?(pieceA1)
    assert       game.pieces['a2'].contains.include?(pieceB2)
    assert_equal game.pieces['a2'].contains.length, 2
    assert_equal game.pieces['b2'].position, game.board.positions['a3']
    assert_equal game.pieces['b2'].captured, true
    assert_equal game.pieces['b2'].contains, []

    game.apply_move(moveA2A, 'a')
    assert_equal game.history.length, 10
    assert_equal game.pieces['a1'].position, game.board.positions['a']
    assert_equal game.pieces['a1'].captured, false
    assert_equal game.pieces['a1'].contains, []
    assert_equal game.pieces['a2'].position, game.board.positions['a']
    assert_equal game.pieces['a2'].captured, false
    assert_equal game.pieces['a2'].contains, []
    assert_equal game.pieces['b2'].position, game.board.positions['a']
    assert_equal game.pieces['b2'].captured, true
    assert_equal game.pieces['b2'].contains, []
  end