Browse Source

BordComputerTest.changeDeviceTest first case

feature-dev-BoardComputer2
sahar 2 years ago
parent
commit
fcaa3473ff
  1. 12
      src/main/java/BordComputer.java
  2. 27
      src/test/java/BordComputerTest.java

12
src/main/java/BordComputer.java

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

27
src/test/java/BordComputerTest.java

@ -81,4 +81,31 @@ class BordComputerTest {
}
return count;
}
////
@ParameterizedTest
@MethodSource("changeDeviceOptions")
void changeDeviceTest(String testName, BordComputer inputBC, Device[] oldDevices,Device prvDevice,String message ,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();
String m = bc.changeDevice();
return Stream.of(
Arguments.of("The order of the installedDevices should be changed ", bc,currentDevices,null,"",1)
);
}
}
Loading…
Cancel
Save