import static org.junit.jupiter.api.Assertions.*;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

class TesterTest {

	@Test
	@DisplayName("Tests opening the lab door")
	public void testMain(){
		System.out.println("main");
	    String[] args = null;
	    	    
	    ByteArrayOutputStream baos = new ByteArrayOutputStream();
	    PrintStream ps = new PrintStream(baos);
	    PrintStream old = System.out;
	    System.setOut(ps);
	    
	    Tester.main(args);
	    System.out.flush();
	    System.setOut(old);
	    
	    String output = baos.toString();
	    System.out.println(output);
	    
	    String expecteda =  "The door won't open!"; 
	    String expectedb =  "The door is open."; 
	    
	    String[] tests = output.split("Trying to open the door to Research Labs...");
	    
	    assertTrue(tests[1].contains(expecteda), "Tests whether the door is locked");
	    assertTrue(tests[2].contains(expectedb), "Tests whether the door is open");
	    
	}

}
