More actions
import static org.junit.Assert.*;
import java.util.Timer;
import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test;
public class testTest {
private Elev el1; private Elev el2;
@Before public void setUp() throws Exception { el1 = new Elev(10,-2); el2 = new Elev(-10,20); }
@After public void tearDown() throws Exception {
}
@Test public void testConstructor1() { Elev el3 = new Elev(10,-2); assertEquals("UP", el3.direction); assertEquals(1, el3.currentFloor); assertEquals(0, el3.Turn); assertEquals(10, el3.maxFloor); assertEquals(-2, el3.minFloor); }
@Test public void testConstructor2() { Elev el3 = new Elev(-2,10); assertEquals("UP", el3.direction); assertEquals(1, el3.currentFloor); assertEquals(0, el3.Turn); assertEquals(10, el3.maxFloor); assertEquals(-2, el3.minFloor); }
@Test public void testConstructor3() { Elev el3 = new Elev(-2,-20); assertEquals("DOWN", el3.direction); assertEquals(-2, el3.currentFloor); assertEquals(0, el3.Turn); assertEquals(-2, el3.maxFloor); assertEquals(-20, el3.minFloor);
}
@Test public void testConstructor4() { Elev el3 = new Elev(3,30); assertEquals("UP", el3.direction); assertEquals(3, el3.currentFloor); assertEquals(0, el3.Turn); assertEquals(30, el3.maxFloor); assertEquals(3, el3.minFloor);
}
@Test
public void testgoTo1() throws Exception {
el1.goTo(4);
assertEquals(3, el1.Turn);
assertEquals(4, el1.currentFloor);
}
@Test(expected = Exception.class) public void testgoTo2() throws Exception { el1.goTo(44); assertEquals(1, el1.currentFloor); }
@Test(expected = Exception.class) public void testgoTo3() throws Exception { el1.goTo(-39); assertEquals(1, el1.currentFloor); }
@Test
public void testupTo1() throws Exception {
el1.upTo(5);
assertEquals(4, el1.Turn);
assertEquals(5, el1.currentFloor);
}
@Test(expected = Exception.class) public void testupTo2() throws Exception { el1.upTo(30); }
@Test(expected = Exception.class) public void testupTo3() throws Exception { el1.upTo(-39); }
@Test(expected = Exception.class) public void testupTo4() throws Exception { el1.upTo(0); }
@Test public void testdownTo1() throws Exception { el1.downTo(5); assertEquals(4, el1.Turn); assertEquals(5, el1.currentFloor); }
@Test(expected = Exception.class) public void testdownTo2() throws Exception { el1.downTo(30); }
@Test(expected = Exception.class) public void testdownTo3() throws Exception { el1.downTo(-39); } @Test(expected = Exception.class) public void testdownTo4() throws Exception { el1.downTo(0); }
@Test public void testpush1() throws Exception { el1.push(5); assertEquals(4, el1.Turn); assertEquals(5, el1.currentFloor); }
@Test(expected = Exception.class) public void testpush2() throws Exception { el1.push(30); }
@Test(expected = Exception.class) public void testpush3() throws Exception { el1.push(-39); } @Test(expected = Exception.class) public void testpush4() throws Exception { el1.push(0); }
@Test public void testcase1() { assertEquals(1, el1.currentFloor); }
}