From efd8ad14f1b996dfd1396179153a6e6086125649 Mon Sep 17 00:00:00 2001 From: sahar Date: Fri, 18 Feb 2022 15:37:20 +0100 Subject: [PATCH] BordComputerTest.changeDeviceTest Second case --- src/main/java/BordComputer.java | 2 ++ src/test/java/BordComputerTest.java | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/BordComputer.java b/src/main/java/BordComputer.java index cfc05d2..1d85deb 100644 --- a/src/main/java/BordComputer.java +++ b/src/main/java/BordComputer.java @@ -43,6 +43,8 @@ public class BordComputer { tempDevices[2]=installedDevices[0]; //replaces the lists installedDevices=tempDevices; + //setting activeDevice + activeDevice =installedDevices[0]; } } diff --git a/src/test/java/BordComputerTest.java b/src/test/java/BordComputerTest.java index eb9ab34..ad293d8 100644 --- a/src/test/java/BordComputerTest.java +++ b/src/test/java/BordComputerTest.java @@ -85,10 +85,13 @@ class BordComputerTest { @ParameterizedTest @MethodSource("changeDeviceOptions") - void changeDeviceTest(String testName, BordComputer inputBC, Device[] oldDevices ,int caseNr) { + void changeDeviceTest(String testName, BordComputer inputBC, Device[] oldDevices,Device prvDevice ,int caseNr) { Device[] newDevicesList = inputBC.installedDevices.clone(); - if (caseNr == 1) { + if (caseNr == 1 ) { assertThat(newDevicesList).describedAs(testName).isNotEqualTo(oldDevices); + }else if (caseNr == 2) { + Device currentDevice = inputBC.activeDevice; + assertThat(currentDevice).describedAs(testName).isNotEqualTo(prvDevice); } } @@ -102,8 +105,16 @@ class BordComputerTest { currentDevices = bc.installedDevices.clone(); bc.changeDevice(); + //second case + BordComputer bc1 = new BordComputer(); + bc1.readConfig(); + bc1.setDevices(); + Device prvDevice = bc1.activeDevice; + bc1.changeDevice(); + return Stream.of( - Arguments.of("The order of the installedDevices should be changed ", bc,currentDevices,1) + Arguments.of("The order of the installedDevices should be changed ", bc,currentDevices,null,1), + Arguments.of("The active Device should be changed ", bc1,null,prvDevice,2) ); }