Browse Source

BordComputerTest.changeDeviceTest First case

feature-dev-BoardComputerTests
sahar 3 years ago
parent
commit
1e7a8129ff
  1. 10
      src/main/java/BordComputer.java
  2. 27
      src/test/java/BordComputerTest.java

10
src/main/java/BordComputer.java

@ -35,4 +35,14 @@ public class BordComputer {
installedDevices[i] = (Device) c.getConstructor().newInstance();
}
}
public void changeDevice() {
Device[] tempDevices=new Device[installedDevices.length];
tempDevices[0]=installedDevices[1];
tempDevices[1]=installedDevices[2];
tempDevices[2]=installedDevices[0];
//replaces the lists
installedDevices=tempDevices;
}
}

27
src/test/java/BordComputerTest.java

@ -1,6 +1,7 @@
import device.Device;
import device.cdPlayer.CDPlayer;
import device.radioPlayer.RadioPlayer;
import device.usbPlayer.USB_Stick;
import device.usbPlayer.UsbPlayer;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
@ -80,5 +81,31 @@ class BordComputerTest {
e.printStackTrace();
}
return count;
}//changeDevice()
@ParameterizedTest
@MethodSource("changeDeviceOptions")
void changeDeviceTest(String testName, BordComputer inputBC, Device[] oldDevices ,int caseNr) {
Device[] newDevicesList = inputBC.installedDevices.clone();
if (caseNr == 1) {
assertThat(newDevicesList).describedAs(testName).isNotEqualTo(oldDevices);
}
}
static Stream<Arguments> changeDeviceOptions() throws ClassNotFoundException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
//first case
BordComputer bc = new BordComputer();
bc.readConfig();
bc.setDevices();
Device[] currentDevices = new Device[bc.installedDevices.length];
currentDevices = bc.installedDevices.clone();
bc.changeDevice();
return Stream.of(
Arguments.of("The order of the installedDevices should be changed ", bc,currentDevices,1)
);
}
}
Loading…
Cancel
Save