From bc0ecd26756f5bdf63642060c9fc3dff2bba941b Mon Sep 17 00:00:00 2001 From: alpina0707 Date: Wed, 16 Feb 2022 22:06:59 +0100 Subject: [PATCH] added second test case for getInfoText() & and added productive code for RadioPlayer --- src/main/java/device/radioPlayer/RadioPlayer.java | 2 +- .../java/device/radioPlayer/RadioPlayerTest.java | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/device/radioPlayer/RadioPlayer.java b/src/main/java/device/radioPlayer/RadioPlayer.java index c319890..f7e39ff 100644 --- a/src/main/java/device/radioPlayer/RadioPlayer.java +++ b/src/main/java/device/radioPlayer/RadioPlayer.java @@ -149,7 +149,7 @@ public class RadioPlayer implements Device { @Override public String getInfoText() { - return "InfoText"; + return playedStation; } @Override diff --git a/src/test/java/device/radioPlayer/RadioPlayerTest.java b/src/test/java/device/radioPlayer/RadioPlayerTest.java index ed7f3ac..704f8e2 100644 --- a/src/test/java/device/radioPlayer/RadioPlayerTest.java +++ b/src/test/java/device/radioPlayer/RadioPlayerTest.java @@ -377,17 +377,21 @@ class RadioPlayerTest { @ParameterizedTest @MethodSource("getInfoTextOptions") - void testGetInfoText(String testName, RadioPlayer testRp, boolean expectedResult) { - Boolean volume = Strings.isNullOrEmpty(testRp.getInfoText()); + void testGetInfoText(String testName, String testTyp, RadioPlayer testRp, boolean expectedResult) { + Boolean bool; + if(testTyp.equals("null")) bool = Strings.isNullOrEmpty(testRp.getInfoText()); + else bool = testRp.getInfoText().contains(testRp.playedStation); - assertThat(volume).describedAs(testName).isEqualTo(expectedResult); + assertThat(bool).describedAs(testName).isEqualTo(expectedResult); } static Stream getInfoTextOptions() { RadioPlayer rp = new RadioPlayer(); + RadioPlayer rp1 = new RadioPlayer(); return Stream.of( - Arguments.of("Test for getInfoText is not empty or null", rp, false) + Arguments.of("Test for getInfoText is not empty or null", "null", rp, false), + Arguments.of("Test for getInfoText contains played station", "station", rp1, true) ); } } \ No newline at end of file