add TestUtil
This commit is contained in:
parent
f863460dba
commit
fc254d069e
@ -1,29 +1,6 @@
|
||||
import { GRClearBoardAtEnd } from '../src/common/game_rules/GRClearBoardAtEnd';
|
||||
import { GRLastStoneInBank } from '../src/common/game_rules/GRLastStoneInBank';
|
||||
import { GRLastStoneInEmptyPit } from '../src/common/game_rules/GRLastStoneInEmptyPit';
|
||||
import { Board } from '../src/core/Board';
|
||||
import { MoveHistoryItem } from '../src/core/HistoryItem';
|
||||
import { MancalaGame } from '../src/core/MancalaGame';
|
||||
|
||||
function createGame(): MancalaGame {
|
||||
const board = new Board(6, 4);
|
||||
const player1Id = '0';
|
||||
const player2Id = '1';
|
||||
const game = new MancalaGame(
|
||||
'0',
|
||||
board,
|
||||
player1Id,
|
||||
player2Id,
|
||||
player1Id,
|
||||
[
|
||||
new GRLastStoneInEmptyPit(),
|
||||
new GRLastStoneInBank(),
|
||||
new GRClearBoardAtEnd()
|
||||
],
|
||||
[]
|
||||
);
|
||||
return game;
|
||||
}
|
||||
import { GameStep, MoveHistoryItem } from '../src/core/HistoryItem';
|
||||
import { GAME_STEP_GAME_MOVE, MancalaGame } from '../src/core/MancalaGame';
|
||||
import { createGame } from './TestUtil';
|
||||
|
||||
describe('Game Test', () => {
|
||||
test('test getPlayerIdByIndex', () => {
|
||||
|
||||
25
tests/TestUtil.ts
Normal file
25
tests/TestUtil.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { GRClearBoardAtEnd } from '../src/common/game_rules/GRClearBoardAtEnd';
|
||||
import { GRLastStoneInBank } from '../src/common/game_rules/GRLastStoneInBank';
|
||||
import { GRLastStoneInEmptyPit } from '../src/common/game_rules/GRLastStoneInEmptyPit';
|
||||
import { Board } from '../src/core/Board';
|
||||
import { MancalaGame } from '../src/core/MancalaGame';
|
||||
|
||||
export function createGame(): MancalaGame {
|
||||
const board = new Board(6, 4);
|
||||
const player1Id = '0';
|
||||
const player2Id = '1';
|
||||
const game = new MancalaGame(
|
||||
'0',
|
||||
board,
|
||||
player1Id,
|
||||
player2Id,
|
||||
player1Id,
|
||||
[
|
||||
new GRLastStoneInEmptyPit(),
|
||||
new GRLastStoneInBank(),
|
||||
new GRClearBoardAtEnd()
|
||||
],
|
||||
[]
|
||||
);
|
||||
return game;
|
||||
}
|
||||
@ -1,28 +1,19 @@
|
||||
import { GRLastStoneInBank } from '../../src/common/game_rules/GRLastStoneInBank';
|
||||
import { GRLastStoneInEmptyPit } from '../../src/common/game_rules/GRLastStoneInEmptyPit';
|
||||
import { GRClearBoardAtEnd } from '../../src/common/game_rules/GRClearBoardAtEnd';
|
||||
import {
|
||||
GAME_STEP_LAST_STONE_IN_BANK,
|
||||
GRLastStoneInBank
|
||||
} from '../../src/common/game_rules/GRLastStoneInBank';
|
||||
import {
|
||||
GAME_STEP_LAST_STONE_IN_EMPTY_PIT,
|
||||
GRLastStoneInEmptyPit
|
||||
} from '../../src/common/game_rules/GRLastStoneInEmptyPit';
|
||||
import {
|
||||
GAME_STEP_BOARD_CLEARED,
|
||||
GRClearBoardAtEnd
|
||||
} from '../../src/common/game_rules/GRClearBoardAtEnd';
|
||||
import { Board } from '../../src/core/Board';
|
||||
import { MancalaGame } from '../../src/core/MancalaGame';
|
||||
|
||||
function createGame(): MancalaGame {
|
||||
const board = new Board(6, 4);
|
||||
const player1Id = '0';
|
||||
const player2Id = '1';
|
||||
const game = new MancalaGame(
|
||||
'0',
|
||||
board,
|
||||
player1Id,
|
||||
player2Id,
|
||||
player1Id,
|
||||
[
|
||||
new GRLastStoneInEmptyPit(),
|
||||
new GRLastStoneInBank(),
|
||||
new GRClearBoardAtEnd()
|
||||
],
|
||||
[]
|
||||
);
|
||||
return game;
|
||||
}
|
||||
import { GAME_STEP_GAME_MOVE, MancalaGame } from '../../src/core/MancalaGame';
|
||||
import { GameStep } from '../../src/core/HistoryItem';
|
||||
import { createGame } from '../TestUtil';
|
||||
|
||||
describe('GRClearBoardAtEnd Test', () => {
|
||||
test('test GRClearBoardAtEnd 1', () => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user