Added factory methods to create cars
This commit is contained in:
parent
13da8b8cee
commit
fc16a47078
|
@ -17,4 +17,20 @@ public class Car {
|
|||
public boolean isManual() {
|
||||
return manual;
|
||||
}
|
||||
|
||||
static Car dieselAndManualCar() {
|
||||
return new Car(true, true);
|
||||
}
|
||||
|
||||
static Car dieselAndAutomaticCar() {
|
||||
return new Car(true, false);
|
||||
}
|
||||
|
||||
static Car oilAndManualCar() {
|
||||
return new Car(false, true);
|
||||
}
|
||||
|
||||
static Car oilAndAutomaticCar() {
|
||||
return new Car(false, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,56 +8,56 @@ class XorUnitTest {
|
|||
|
||||
@Test
|
||||
void givenDieselManualCar_whenXorOldSchool_ThenFalse() {
|
||||
Car car = new Car(true, true);
|
||||
Car car = Car.dieselAndManualCar();
|
||||
boolean dieselXorManual = (car.isDiesel() && !car.isManual()) || (!car.isDiesel() && car.isManual());
|
||||
assertThat(dieselXorManual).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenDieselAutomaticCar_whenXorOldSchool_ThenTrue() {
|
||||
Car car = new Car(true, false);
|
||||
Car car = Car.dieselAndAutomaticCar();
|
||||
boolean dieselXorManual = (car.isDiesel() && !car.isManual()) || (!car.isDiesel() && car.isManual());
|
||||
assertThat(dieselXorManual).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenNonDieselManualCar_whenXorOldSchool_ThenTrue() {
|
||||
Car car = new Car(false, true);
|
||||
Car car = Car.oilAndManualCar();
|
||||
boolean dieselXorManual = (car.isDiesel() && !car.isManual()) || (!car.isDiesel() && car.isManual());
|
||||
assertThat(dieselXorManual).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenNonDieselAutomaticCar_whenXorOldSchool_ThenFalse() {
|
||||
Car car = new Car(false, false);
|
||||
Car car = Car.oilAndAutomaticCar();
|
||||
boolean dieselXorManual = (car.isDiesel() && !car.isManual()) || (!car.isDiesel() && car.isManual());
|
||||
assertThat(dieselXorManual).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenDieselManualCar_whenXor_ThenFalse() {
|
||||
Car car = new Car(true, true);
|
||||
Car car = Car.dieselAndManualCar();
|
||||
boolean dieselXorManual = car.isDiesel() ^ car.isManual();
|
||||
assertThat(dieselXorManual).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenDieselAutomaticCar_whenXor_ThenTrue() {
|
||||
Car car = new Car(true, false);
|
||||
Car car = Car.dieselAndAutomaticCar();
|
||||
boolean dieselXorManual = car.isDiesel() ^ car.isManual();
|
||||
assertThat(dieselXorManual).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenNonDieselManualCar_whenXor_ThenTrue() {
|
||||
Car car = new Car(false, true);
|
||||
Car car = Car.oilAndManualCar();
|
||||
boolean dieselXorManual = car.isDiesel() ^ car.isManual();
|
||||
assertThat(dieselXorManual).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenNonDieselAutomaticCar_whenXor_ThenFalse() {
|
||||
Car car = new Car(false, false);
|
||||
Car car = Car.oilAndAutomaticCar();
|
||||
boolean dieselXorManual = car.isDiesel() ^ car.isManual();
|
||||
assertThat(dieselXorManual).isFalse();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue