// 走行中にはPへのシフトを無視する @Test public void ignoresShiftToParkWhileInDrive() { transmission.shift(Gear.DRIVE); car.accelerateTo(30); transmission.shift(Gear.PARK); assertThat(transmission.getGear(), equalTo(Gear.DRIVE)); }
// 停止中はPにシフトできる @Test public void allowsShiftToParkWhenNotMoving() { transmission.shift(Gear.DRIVE); car.accelerateTo(30); car.brakeToStop(); transmission.shift(Gear.PARK); assertThat(transmission.getGear(), equalTo(Gear.PARK)); }
// 加速を始めたらDの状態を保つ @Test public void remainsInDriveAfterAcceleration() { transmission.shift(Gear.DRIVE); car.accelerateTo(35); assertThat(transmission.getGear(), equalTo(Gear.DRIVE)); }