package net.raymanoz.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import net.raymanoz.ui.GUIInteractionStrategy;
import net.raymanoz.ui.UserInteractionStrategy;
import org.junit.Test;
import static org.mockito.Mockito.*;
public class UserInteractionStrategyTest {
final private Configuration config = mock(Configuration.class);
//TODO - this will not be simple :(
@Test
public void shouldBeAbleToCreate() {
UserInteractionStrategy confirmation = new GUIInteractionStrategy(config, "message");
assertNotNull("could not create " + GUIInteractionStrategy.class.getName(), confirmation);
}
/*@Test
public void confirmationMessageShouldBeDispalyed() {
String expectedMessage = "message";
UserInteractionStrategy confirmation = new GUIInteractionStrategy(config, expectedMessage);
ByteArrayOutputStream output = new ByteArrayOutputStream();
System.setOut(new PrintStream(output, true));
System.setIn(new ByteArrayInputStream("Y\n".getBytes()));
confirmation.ask();
assertTrue("Confirmation message should've been displayed", output.toString().contains(expectedMessage));
}
@Test
public void askReturnsTrueIfUserSaysYes() {
assertAnswer("Y", true);
assertAnswer("y", true);
assertAnswer("N", false);
assertAnswer("n", false);
assertAnswer("Yo", false);
}
private void assertAnswer(String userInput, boolean expectedResult) {
String expectedMessage = "message";
UserInteractionStrategy confirmation = new GUIInteractionStrategy(config, expectedMessage);
System.setIn(new ByteArrayInputStream((userInput + "\n").getBytes()));
assertEquals("Confirmation message returned wrong result for '" + userInput + "'",
//expectedResult, confirmation.ask());
}*/
}