Skip to content

Commit

Permalink
final changes!
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateful committed Jan 11, 2012
1 parent 36e8827 commit 49f6862
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 540 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import de.fhb.projects.Twitchess.controller.UCIEngineInterface;
import de.fhb.projects.Twitchess.controller.chesscommands.MoveChessCommand.MoveType;
import de.fhb.projects.Twitchess.controller.configuration.Configuration;
import de.fhb.projects.Twitchess.data.ChessStateDAOInterface;
import de.fhb.projects.Twitchess.data.ChessStateVO;
import de.fhb.projects.Twitchess.exception.ChessManagerException;
Expand Down Expand Up @@ -74,7 +75,7 @@ public void testProcessInputAi() throws Throwable {
EasyMock.expect(
uci.calculateMove(
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
2000)).andReturn("a2a3");
Configuration.getInt("Engine.TimePerMove", 2000))).andReturn("a2a3");
uci.destroy();
dao.updateTable(vo);
EasyMock.replay(dao);
Expand Down Expand Up @@ -115,7 +116,7 @@ public void testProcessInputBoth() throws Throwable {
EasyMock.expect(
uci.calculateMove(
"rnbqkbnr/pppppppp/8/8/8/P7/1PPPPPPP/RNBQKBNR b KQkq - 0 1",
2000)).andReturn("a7a6");
Configuration.getInt("Engine.TimePerMove", 2000))).andReturn("a7a6");
uci.destroy();
dao.updateTable(vo);
EasyMock.replay(dao);
Expand All @@ -137,7 +138,7 @@ public void testProcessInputInvalidMove() throws Throwable {
EasyMock.expect(
uci.calculateMove(
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
2000)).andReturn("a2a3");
Configuration.getInt("Engine.TimePerMove", 2000))).andReturn("a2a3");
uci.destroy();
dao.updateTable(vo);
EasyMock.replay(dao);
Expand All @@ -156,7 +157,7 @@ public void testProcessInputOutOfFieldMove() throws Throwable {
EasyMock.expect(
uci.calculateMove(
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
2000)).andReturn("a2a3");
Configuration.getInt("Engine.TimePerMove", 2000))).andReturn("a2a3");
uci.destroy();
dao.updateTable(vo);
EasyMock.replay(dao);
Expand All @@ -175,7 +176,7 @@ public void testProcessInputInvalidMoveAI() throws Throwable {
EasyMock.expect(
uci.calculateMove(
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
2000)).andReturn("a7k5");
Configuration.getInt("Engine.TimePerMove", 2000))).andReturn("a7k5");
uci.destroy();
dao.updateTable(vo);
EasyMock.replay(dao);
Expand All @@ -194,7 +195,7 @@ public void testProcessInputValidMove() throws Throwable {
EasyMock.expect(
uci.calculateMove(
"rnbqkbnr/pppppppp/8/8/8/2P5/PP1PPPPP/RNBQKBNR b KQkq - 0 1",
2000)).andReturn("a7a6");
Configuration.getInt("Engine.TimePerMove", 2000))).andReturn("a7a6");
uci.destroy();
dao.updateTable(vo);
EasyMock.replay(dao);
Expand All @@ -215,7 +216,7 @@ public void testProcessInputUCIExeption() throws Throwable {
EasyMock.expect(
uci.calculateMove(
"rnbqkbnr/pppppppp/8/8/8/2P5/PP1PPPPP/RNBQKBNR b KQkq - 0 1",
2000)).andThrow(new UCIException(""));
Configuration.getInt("Engine.TimePerMove", 2000))).andThrow(new UCIException(""));
uci.destroy();
dao.updateTable(vo);
EasyMock.replay(dao);
Expand Down Expand Up @@ -390,7 +391,7 @@ public void testPromotion() throws Throwable {
EasyMock.expect(
uci.calculateMove(
"r1bqkbnr/pppp1ppp/2n5/4P3/8/5N2/P1Q2PPP/nNB1KB1R w Kkq - 0 7",
2000)).andReturn("c2b2");
Configuration.getInt("Engine.TimePerMove", 2000))).andReturn("c2b2");
uci.destroy();
dao.updateTable(vo);
EasyMock.replay(dao);
Expand Down Expand Up @@ -445,7 +446,7 @@ public void testIsGameOverCheckMateAI() throws Throwable {
EasyMock.expect(
uci.calculateMove(
"rnbqkbnr/1ppp1pp1/7p/p3p3/2B1P3/5Q2/PPPP1PPP/RNB1K1NR w KQkq a6 0 4",
2000)).andReturn("f3f7");
Configuration.getInt("Engine.TimePerMove", 2000))).andReturn("f3f7");
uci.destroy();
dao.updateTable(vo);
EasyMock.replay(dao);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import de.fhb.projects.Twitchess.controller.UCIEngineInterface;
import de.fhb.projects.Twitchess.controller.chesscommands.OfferDrawChessCommand;
import de.fhb.projects.Twitchess.controller.configuration.Configuration;
import de.fhb.projects.Twitchess.data.ChessStateDAOInterface;
import de.fhb.projects.Twitchess.data.ChessStateVO;
import de.fhb.projects.Twitchess.exception.ChessManagerException;
Expand Down Expand Up @@ -82,12 +83,14 @@ public void testProcessInput() throws Throwable{
vo.setId(1);
EasyMock.expect(dao.findNotFinishedGameByPlayer("player1")).andReturn(state);
uci.init();
EasyMock.expect(uci.calculateScore("7k/8/8/8/8/8/8/7K w KQkq - 20 21", 2000)).andReturn(10);
EasyMock.expect(
uci.calculateScore("7k/8/8/8/8/8/8/7K w KQkq - 20 21",
Configuration.getInt("Engine.TimePerMove", 2000))).andReturn(10);
dao.updateTable(vo);
uci.destroy();
EasyMock.replay(uci);
EasyMock.replay(dao);
assertEquals("Fair enough, I accept your offer! {7k/8/8/8/8/8/8/7K w KQkq - 20 21}",odcc.processInput("player1", parameters));
assertEquals("Fair enough, I accept your offer! Score = 10 {7k/8/8/8/8/8/8/7K w KQkq - 20 21}",odcc.processInput("player1", parameters));
EasyMock.verify(uci);
EasyMock.verify(dao);
}
Expand All @@ -96,11 +99,11 @@ public void testProcessInput() throws Throwable{
public void testProcessInputDontAcceptDraw() throws Throwable{
EasyMock.expect(dao.findNotFinishedGameByPlayer("player1")).andReturn(state);
uci.init();
EasyMock.expect(uci.calculateScore("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", 2000)).andReturn(100);
EasyMock.expect(uci.calculateScore("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", Configuration.getInt("Engine.TimePerMove", 2000))).andReturn(100);
uci.destroy();
EasyMock.replay(uci);
EasyMock.replay(dao);
assertEquals("It is too early to call it a draw!",odcc.processInput("player1", parameters));
assertEquals("It is too early to call it a draw! Score = 100",odcc.processInput("player1", parameters));
EasyMock.verify(uci);
EasyMock.verify(dao);
}
Expand All @@ -119,7 +122,7 @@ public void testProcessInputIOException() throws SQLException, IOException, Ches
public void testProcessInputThrowableException() throws Throwable{
EasyMock.expect(dao.findNotFinishedGameByPlayer("player1")).andReturn(state);
uci.init();
EasyMock.expect(uci.calculateScore("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", 2000)).andReturn(100);
EasyMock.expect(uci.calculateScore("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", Configuration.getInt("Engine.TimePerMove", 2000))).andReturn(100);
uci.destroy();
EasyMock.expectLastCall().andThrow(new Throwable());
EasyMock.replay(uci);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void testProcessInput() throws SQLException, ChessManagerException {
EasyMock.expect(dao.findNotFinishedGameByPlayer("player1")).andReturn(
state);
EasyMock.replay(dao);
assertEquals("Current Position: {"
assertEquals("FEN: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 {"
+ "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
+ "}", chessCommand.processInput("player1", parameters));
EasyMock.verify(dao);
Expand Down Expand Up @@ -78,7 +78,7 @@ public void testProcessInputNullParameter() throws SQLException,
EasyMock.expect(dao.findNotFinishedGameByPlayer("player1")).andReturn(
state);
EasyMock.replay(dao);
assertEquals("Current Position: {"
assertEquals("FEN: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 {"
+ "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
+ "}", chessCommand.processInput("player1", null));
EasyMock.verify(dao);
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 49f6862

Please sign in to comment.