tests + ado equals override
This commit is contained in:
@@ -3,12 +3,57 @@
|
||||
*/
|
||||
package chess;
|
||||
|
||||
import chess.ai.DumbAI;
|
||||
import chess.controller.Command;
|
||||
import chess.controller.CommandExecutor;
|
||||
import chess.controller.commands.NewGameCommand;
|
||||
import chess.controller.commands.UndoCommand;
|
||||
import chess.controller.event.GameAdaptator;
|
||||
import chess.model.*;
|
||||
import chess.model.pieces.*;
|
||||
import chess.simulator.Simulator;
|
||||
import chess.view.simplerender.Window;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
class AppTest {
|
||||
@Test void appHasAGreeting() {
|
||||
// App classUnderTest = new App();
|
||||
// assertNotNull(classUnderTest.getGreeting(), "app should have a greeting");
|
||||
@Test void functionalRollback(){
|
||||
Game game = new Game(new ChessBoard());
|
||||
CommandExecutor commandExecutor = new CommandExecutor(game);
|
||||
|
||||
DumbAI ai = new DumbAI(commandExecutor, Color.Black);
|
||||
commandExecutor.addListener(ai);
|
||||
|
||||
DumbAI ai2 = new DumbAI(commandExecutor, Color.White);
|
||||
commandExecutor.addListener(ai2);
|
||||
|
||||
commandExecutor.addListener(new GameAdaptator() {
|
||||
@Override
|
||||
public void onGameEnd() {
|
||||
|
||||
Command.CommandResult result;
|
||||
do {
|
||||
result = commandExecutor.executeCommand(new UndoCommand());
|
||||
} while (result != Command.CommandResult.NotAllowed);
|
||||
|
||||
Game initialGame = new Game(new ChessBoard());
|
||||
CommandExecutor initialCommandExecutor = new CommandExecutor(initialGame);
|
||||
commandExecutor.executeCommand(new NewGameCommand());
|
||||
|
||||
assert(game.getBoard().equals(initialGame.getBoard()));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
commandExecutor.executeCommand(new NewGameCommand());
|
||||
|
||||
}
|
||||
|
||||
@Test void functionalRollbacks(){
|
||||
for (int i=0; i<100; i++) {
|
||||
functionalRollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user