Commit e17d5c7f authored by Gaetan's avatar Gaetan

Modification des tests unitaires

parent 19ea9300
import garage.Garage;
import org.junit.Before;
import org.junit.Test;
import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertNull;
public class GarageTest {
private Garage garage;
}
package test;
import garage.ExecutionFailedException;
import garage.Task;
import garage.TestBench;
......@@ -34,72 +36,72 @@ public class TestBenchTest {
@Test
public void addVehicleTest(){
assertNull(testBench.getVehicle());
Assert.assertNull(testBench.getVehicle());
testBench.addVehicle(fiat500);
assertEquals(fiat500, testBench.getVehicle());
TestCase.assertEquals(fiat500, testBench.getVehicle());
}
@Test
public void addVehicleImpossibleTest(){
assertNull(testBench.getVehicle());
Assert.assertNull(testBench.getVehicle());
testBench.addVehicle(fiat500);
testBench.addVehicle(peugeot5008);
assertEquals(fiat500, testBench.getVehicle());
TestCase.assertEquals(fiat500, testBench.getVehicle());
}
@Test
public void removeVehicleTest(){
testBench.addVehicle(fiat500);
assertEquals(fiat500, testBench.getVehicle());
TestCase.assertEquals(fiat500, testBench.getVehicle());
testBench.removeVehicle();
assertNull(testBench.getVehicle());
Assert.assertNull(testBench.getVehicle());
}
@Test
public void removeVehicleImpossibleTest(){
testBench.removeVehicle();
assertNull(testBench.getVehicle());
Assert.assertNull(testBench.getVehicle());
}
@Test
public void swapVehicleTest(){
testBench.addVehicle(fiat500);
assertEquals(fiat500, testBench.getVehicle());
TestCase.assertEquals(fiat500, testBench.getVehicle());
Vehicle swapped = testBench.swapVehicle(peugeot5008);
assertEquals(fiat500, swapped);
assertEquals(peugeot5008, testBench.getVehicle());
TestCase.assertEquals(fiat500, swapped);
TestCase.assertEquals(peugeot5008, testBench.getVehicle());
}
@Test
public void swapVehicleImpossibleTest(){
Vehicle swapped = testBench.swapVehicle(peugeot5008);
assertNull(swapped);
assertNull(testBench.getVehicle());
Assert.assertNull(swapped);
Assert.assertNull(testBench.getVehicle());
}
@Test
public void addTaskTest(){
assertEquals(0, testBench.getTasks().size());
TestCase.assertEquals(0, testBench.getTasks().size());
testBench.addTask(task);
assertEquals(1, testBench.getTasks().size());
assertTrue(testBench.getTasks().contains(task));
TestCase.assertEquals(1, testBench.getTasks().size());
TestCase.assertTrue(testBench.getTasks().contains(task));
}
@Test
public void removeTaskTest(){
testBench.addTask(task);
assertEquals(1, testBench.getTasks().size());
TestCase.assertEquals(1, testBench.getTasks().size());
testBench.removeTask(task);
assertEquals(0, testBench.getTasks().size());
TestCase.assertEquals(0, testBench.getTasks().size());
}
@Test
public void runTest(){
testBench.addVehicle(fiat500);
testBench.addTask(task);
assertEquals(0d, fiat500.getPedals().get(0).getState());
TestCase.assertEquals(0d, fiat500.getPedals().get(0).getState());
testBench.run(10);
assertEquals(50d, fiat500.getPedals().get(0).getState());
TestCase.assertEquals(50d, fiat500.getPedals().get(0).getState());
}
@Test
......@@ -119,9 +121,9 @@ public class TestBenchTest {
testBench.addTask(new Task(fiat500.getGearBox(), "gearUp", null, 3));
testBench.addTask(new Task(fiat500.getPedals().get(PedalPosition.CLUTCH.getValue()), "setState", Arrays.asList(0d), 4));
assertEquals(Gear.NEUTRAL, fiat500.getGearBox().getCurrentGear());
TestCase.assertEquals(Gear.NEUTRAL, fiat500.getGearBox().getCurrentGear());
testBench.run(10);
assertEquals(Gear.FIRST, fiat500.getGearBox().getCurrentGear());
TestCase.assertEquals(Gear.FIRST, fiat500.getGearBox().getCurrentGear());
}
}
import vehicle.part.option.Aircon;
import vehicle.part.option.CareerBars;
import vehicle.part.option.Option;
import java.util.List;
public class TestVehicle {
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment