package com.truphone.cascades;

import java.io.PrintStream;

import org.junit.Assert;
import org.junit.Test;

import com.truphone.cascades.FakeDevice.FakeDeviceListener;
import com.truphone.cascades.commands.ToastCommand;
import com.truphone.cascades.replys.IReply;
/**
 * Test class.
 * @author STruscott
 *
 */
public final class TestToastCommand {
	/**
	 * Test the toast command.
	 * @throws TimeoutException Thrown if the command times out
	 */
	@Test
	public void testToastCommand() throws TimeoutException {
		final FakeDeviceListener response = new FakeDeviceListener() {
			@Override
			public void messageReceived(String message, PrintStream replyStream) {
				if ("toast You didn't enter a password".equals(message)) {
					replyStream.println(FakeDevice.OK_MESSAGE);
				} else {
					Assert.fail(message);
				}
			}
		};
		FakeDevice.DEVICE.getProcess().addListener(response);
		final IReply reply = FakeDevice.CONN.transmit(new ToastCommand(
				"You didn't enter a password"), FakeDevice.DEFAULT_TIMEOUT);
		FakeDevice.DEVICE.getProcess().removeListener(response);
		Assert.assertTrue(reply.isSuccess());
	}
}

@@ -1116,11 +1116,1463 @@
 s());%0A%09%7D
+%0A%0A%09/**%0A%09 * Test the toast command.%0A%09 * @throws TimeoutException Thrown if the command times out%0A%09 */%0A%09@Test%0A%09public void testToastOnCommand() throws TimeoutException %7B%0A%09%09final FakeDeviceListener response = new FakeDeviceListener() %7B%0A%09%09%09@Override%0A%09%09%09public void messageReceived(String message, PrintStream replyStream) %7B%0A%09%09%09%09if (%22toast true%22.equals(message)) %7B%0A%09%09%09%09%09replyStream.println(FakeDevice.OK_MESSAGE);%0A%09%09%09%09%7D else %7B%0A%09%09%09%09%09Assert.fail(message);%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D;%0A%09%09FakeDevice.DEVICE.getProcess().addListener(response);%0A%09%09final IReply reply = FakeDevice.CONN.transmit(new ToastCommand(true), FakeDevice.DEFAULT_TIMEOUT);%0A%09%09FakeDevice.DEVICE.getProcess().removeListener(response);%0A%09%09Assert.assertTrue(reply.isSuccess());%0A%09%7D%0A%0A%09/**%0A%09 * Test the toast command.%0A%09 * @throws TimeoutException Thrown if the command times out%0A%09 */%0A%09@Test%0A%09public void testToastHiddenCommand() throws TimeoutException %7B%0A%09%09final FakeDeviceListener response = new FakeDeviceListener() %7B%0A%09%09%09@Override%0A%09%09%09public void messageReceived(String message, PrintStream replyStream) %7B%0A%09%09%09%09if (%22toast false%22.equals(message)) %7B%0A%09%09%09%09%09replyStream.println(FakeDevice.OK_MESSAGE);%0A%09%09%09%09%7D else %7B%0A%09%09%09%09%09Assert.fail(message);%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D;%0A%09%09FakeDevice.DEVICE.getProcess().addListener(response);%0A%09%09final IReply reply = FakeDevice.CONN.transmit(new ToastCommand(false), FakeDevice.DEFAULT_TIMEOUT);%0A%09%09FakeDevice.DEVICE.getProcess().removeListener(response);%0A%09%09Assert.assertTrue(reply.isSuccess());%0A%09%7D
 %0A%7D%0A

Update the Toast unit tests.