// Test 3.
// Sent 15 of them, none completed.
try {
for (int i=0; i < 15; i++) {
GcodeCommand command = new GcodeCommand("G0 X1");
command.setSent(true);
command.setResponse("ok");
instance.commandSent(command.getCommandString());
}
} catch (Exception ex) {
ex.printStackTrace();
fail("Unexpected exception from command sent: " + ex.getMessage());
}
expResult = 30;
result = instance.rowsInSend();
assertEquals(expResult, result);
expResult = 15;
result = instance.rowsSent();
assertEquals(expResult, result);
expResult = 30;
result = instance.rowsRemaining();
assertEquals(expResult, result);
// Test 4.
// Complete 15 of them.
try {
for (int i=0; i < 15; i++) {
GcodeCommand command = new GcodeCommand("G0X1"); // Whitespace removed.
command.setSent(true);
command.setResponse("ok");
instance.commandComplete(command.getCommandString());
}
} catch (Exception ex) {
ex.printStackTrace();
fail("Unexpected exception from command complete: " + ex.getMessage());
}
expResult = 30;
result = instance.rowsInSend();
assertEquals(expResult, result);
expResult = 15;
result = instance.rowsSent();
assertEquals(expResult, result);
expResult = 15;
result = instance.rowsRemaining();
assertEquals(expResult, result);
// Test 5.
// Finish sending/completing the remaining 15 commands.
try {
for (int i=0; i < 15; i++) {
GcodeCommand command = new GcodeCommand("G0 X1");
command.setSent(true);
command.setResponse("ok");
instance.commandSent(command.getCommandString());
instance.commandComplete(command.getCommandString());
}
} catch (Exception ex) {
ex.printStackTrace();
fail("Unexpected exception from command complete: " + ex.getMessage());
}