added some testmethods for the client testing the statechanges in the dialogs

This commit is contained in:
Benjamin Feyer
2024-11-24 19:03:19 +01:00
committed by Felix
parent 1b2d4df96f
commit 436dae4ebc

View File

@@ -314,14 +314,17 @@ public void testClientInterruptToGame() {
*/
@Test
public void testInterruptToDialogs() {
//TODO
//sends the ClientAutomaton in GameState
clientAutomaton.gotoState(interrupt);
//tests if the client is in GameState
assertTrue(clientAutomaton.getState() instanceof Interrupt);
//Todo
//Todo send the server-closed message and the leave option
assertTrue(clientAutomaton.getState() instanceof Dialogs);
Dialogs dialogs1 = (Dialogs) clientAutomaton.getState();
DialogsStateMachine dialogsStateMachine1 = dialogs1.getDialogsStateMachine();
assertTrue(dialogsStateMachine1.getState() instanceof StartDialog);
}
/**
@@ -329,12 +332,21 @@ public void testInterruptToDialogs() {
*/
@Test
public void testCeremonyToDialogs() {
// Todo Implementation goes here
//send the client in the ceremony
clientAutomaton.gotoState(ceremony);
assertTrue(clientAutomaton.getStates() instanceof Ceremony);
assertTrue(clientAutomaton.getState() instanceof Ceremony);
//Todo
//sends the ceremony machine in the statistics
CeremonyStateMachine ceremonyStateMachine1 = ceremony.getCeremonyStateMachine();
ceremonyStateMachine1.gotoState(statistics);
assertTrue(ceremonyStateMachine1.getState() instanceof Statistics);
//Todo simulate the button next
assertTrue(clientAutomaton.getState() instanceof Dialogs);
Dialogs dialogs1 = (Dialogs) clientAutomaton.getState();
DialogsStateMachine dialogsStateMachine1 = dialogs1.getDialogsStateMachine();
assertTrue(dialogsStateMachine1.getState() instanceof StartDialog);
}
/**
@@ -342,7 +354,19 @@ public void testCeremonyToDialogs() {
*/
@Test
public void testStartDialogToNetworkDialog1() {
// Implementation goes here
// sends the clientAutomaton in StartDialog
clientAutomaton.gotoState(dialogs);
assertTrue(clientAutomaton.getState() instanceof Dialogs);
//sends the DialogsStateMachine in StartDialog
DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine();
dialogsStateMachine1.gotoState(startDialog);
assertTrue(dialogsStateMachine1.getState() instanceof StartDialog);
//todo simulate pushBtn as client or host
assertTrue(clientAutomaton.getState() instanceof Dialogs);
assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog);
}
/**
@@ -350,7 +374,19 @@ public void testStartDialogToNetworkDialog1() {
*/
@Test
public void testStartDialogToNetworkDialog2() {
// Implementation goes here
// sends the clientAutomaton in StartDialog
clientAutomaton.gotoState(dialogs);
assertTrue(clientAutomaton.getState() instanceof Dialogs);
//sends the DialogsStateMachine in StartDialog
DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine();
dialogsStateMachine1.gotoState(startDialog);
assertTrue(dialogsStateMachine1.getState() instanceof StartDialog);
//todo simulate pushBtn as client or host
assertTrue(clientAutomaton.getState() instanceof Dialogs);
assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog);
}
/**
@@ -359,6 +395,7 @@ public void testStartDialogToNetworkDialog2() {
@Test
public void testStartDialogToDialogsEndState() {
// Implementation goes here
//TODO how to test?
}
/**
@@ -366,7 +403,19 @@ public void testStartDialogToDialogsEndState() {
*/
@Test
public void testNetworkDialogToStartDialog() {
// Implementation goes here
// sends the clientAutomaton in StartDialog
clientAutomaton.gotoState(dialogs);
assertTrue(clientAutomaton.getState() instanceof Dialogs);
//sends the DialogsStateMachine in NetworkDialog
DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine();
dialogsStateMachine1.gotoState(networkDialog);
assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog);
//todo simulate pushBtn
assertTrue(clientAutomaton.getState() instanceof Dialogs);
assertTrue(dialogsStateMachine1.getState() instanceof StartDialog);
}
/**
@@ -374,7 +423,19 @@ public void testNetworkDialogToStartDialog() {
*/
@Test
public void testNetworkDialogToNetworkDialog1() {
// Implementation goes here
// sends the clientAutomaton in StartDialog
clientAutomaton.gotoState(dialogs);
assertTrue(clientAutomaton.getState() instanceof Dialogs);
//sends the DialogsStateMachine in NetworkDialog
DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine();
dialogsStateMachine1.gotoState(networkDialog);
assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog);
//todo test receiving all messages and making input
assertTrue(clientAutomaton.getState() instanceof Dialogs);
assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog);
}
/**
@@ -382,7 +443,24 @@ public void testNetworkDialogToNetworkDialog1() {
*/
@Test
public void testNetworkDialogToNetworkDialog2() {
// Implementation goes here
// sends the clientAutomaton in StartDialog
clientAutomaton.gotoState(dialogs);
assertTrue(clientAutomaton.getState() instanceof Dialogs);
//sends the DialogsStateMachine in NetworkDialog
DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine();
dialogsStateMachine1.gotoState(networkDialog);
assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog);
//todo simulate try connect to server ith wrong variables
assertTrue(clientAutomaton.getState() instanceof Dialogs);
assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog);
//todo simulate try connect to server with send: join-lobby and receive lobby-refuse-message
assertTrue(clientAutomaton.getState() instanceof Dialogs);
assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog);
}
/**
@@ -390,7 +468,19 @@ public void testNetworkDialogToNetworkDialog2() {
*/
@Test
public void testNetworkDialogToLobby() {
// Implementation goes here
// sends the clientAutomaton in StartDialog
clientAutomaton.gotoState(dialogs);
assertTrue(clientAutomaton.getState() instanceof Dialogs);
//sends the DialogsStateMachine in NetworkDialog
DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine();
dialogsStateMachine1.gotoState(networkDialog);
assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog);
//todo simulate connect to server with send lobby request
assertTrue(clientAutomaton.getState() instanceof Dialogs);
assertTrue(dialogsStateMachine1.getState() instanceof Lobby);
}
/**
@@ -398,7 +488,19 @@ public void testNetworkDialogToLobby() {
*/
@Test
public void testLobbyToStartDialog() {
// Implementation goes here
// sends the clientAutomaton in StartDialog
clientAutomaton.gotoState(dialogs);
assertTrue(clientAutomaton.getState() instanceof Dialogs);
//sends the DialogsStateMachine in Lobby
DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine();
dialogsStateMachine1.gotoState(lobby);
assertTrue(dialogsStateMachine1.getState() instanceof Lobby);
//todo simulate leave the lobby
assertTrue(clientAutomaton.getState() instanceof Dialogs);
assertTrue(dialogsStateMachine1.getState() instanceof StartDialog);
}
/**
@@ -406,7 +508,19 @@ public void testLobbyToStartDialog() {
*/
@Test
public void testStayInLobby() {
// Implementation goes here
// sends the clientAutomaton in StartDialog
clientAutomaton.gotoState(dialogs);
assertTrue(clientAutomaton.getState() instanceof Dialogs);
//sends the DialogsStateMachine in Lobby
DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine();
dialogsStateMachine1.gotoState(lobby);
assertTrue(dialogsStateMachine1.getState() instanceof Lobby);
//todo send all messages that dont indicate a change-state
assertTrue(clientAutomaton.getState() instanceof Dialogs);
assertTrue(dialogsStateMachine1.getState() instanceof Lobby);
}
/**