import static org.junit.Assert.*;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.io.PrintStream;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.jmock.Mockery;
import org.jmock.Expectations;
import org.jmock.lib.legacy.ClassImposteriser;
import ProcessingLogic.Counter;
import ProcessingLogic.Word;
import StorageLogic.WordFrequency;
public class UnitTests {
private Mockery context = new Mockery() {{
setImposteriser(ClassImposteriser.INSTANCE);
}};
private main mn;
private Counter counter;
@Before
public void setMinimalMockingExpectations
() throws IOException { mn = context.mock(main.class);
counter = context.mock(Counter.class);
}
@After
public void reset() {
}
//File associated errors
@Test
public void EnsureFileCheckExists
() throws IOException { final String DNE
= "Does not exist";
Expectations exp;
exp = new Expectations() {{
//one(mn).main(null);
//one(mn).promptStringOrFile(); will(returnValue(true)); //use parameter here
one(mockOut).println("Do you want to process standard (I)nput, or a (F)ile? I/F");
one(reader).read(new char[2], 0,1);
//one(mn).grabConfig(); will(returnValue(new String[] {"-1", "1"}));
one(mockOut).println("How many results would you like to see? (-1 for all)");
//one(mn).readInput(); will(returnValue("-1"));
//one(mn).readInput(); will(returnValue(DNE));
//one(mn).ensureFileExists(DNE); will(returnValue(false));
}};
context.checking(exp);
main.main(null);
}
}