From fc98df250dfd70538ee1aa7d86dfe44efeed8d1e Mon Sep 17 00:00:00 2001 From: alpina0707 Date: Thu, 17 Feb 2022 02:00:44 +0100 Subject: [PATCH] revised test for RadioPlayer getYouFMInfoByTime() --- .../device/radioPlayer/RadioPlayerTest.java | 45 ++++++------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/src/test/java/device/radioPlayer/RadioPlayerTest.java b/src/test/java/device/radioPlayer/RadioPlayerTest.java index b0dae7a..51a85cf 100644 --- a/src/test/java/device/radioPlayer/RadioPlayerTest.java +++ b/src/test/java/device/radioPlayer/RadioPlayerTest.java @@ -101,40 +101,23 @@ class RadioPlayerTest { ); } - @Test - void YouFMInfoByTimeTest() { - RadioPlayer rp = new RadioPlayer(); - assertThat(rp.getYouFMInfoByTime(8)).describedAs("YouFM info by Time at 8.00").isEqualTo("YOUFM Good Morning Show"); - } - - @Test - void YouFMInfoByTime2Test() { - RadioPlayer rp = new RadioPlayer(); - assertThat(rp.getYouFMInfoByTime(3)).describedAs("YouFM info by Time at 3.00").isEqualTo("YOUFM Junge Nacht der ARD"); - } - - @Test - void AntenneBYInfoByTimeTest() { - RadioPlayer rp = new RadioPlayer(); - assertThat(rp.getAntenneBYInfoByTime(8)).describedAs("AntenneBY info by Time at 8.00").isEqualTo("ANTENNE BAYERN Guten Morgen Bayern"); - } - - @Test - void AntenneBYInfoByTime2Test() { - RadioPlayer rp = new RadioPlayer(); - assertThat(rp.getAntenneBYInfoByTime(3)).describedAs("AntenneBY info by Time at 3.00").isEqualTo("ANTENNE BAYERN Hit-Nacht"); - } - - @Test - void BR3InfoByTimeTest() { - RadioPlayer rp = new RadioPlayer(); - assertThat(rp.getBR3InfoByTime(5)).describedAs("BR3 info by Time at 5.00").isEqualTo("Sebastian Winkler und die Frühaufdreher"); + @ParameterizedTest + @MethodSource("infoByTimeOptions") + void infoByTimeInfo(String testName, RadioPlayer testRp, String testTyp, int hour, String expectedResult) { + if(testTyp.equals("YouFm")) assertThat(testRp.getYouFMInfoByTime(hour)).describedAs(testName).isEqualTo(expectedResult); } - @Test - void BR3InfoByTime2Test() { + static Stream infoByTimeOptions() { RadioPlayer rp = new RadioPlayer(); - assertThat(rp.getBR3InfoByTime(21)).describedAs("BR3 info by Time at 21.00").isEqualTo("Matuschke - der etwas andere Abend"); + return Stream.of( + Arguments.of("Station info YouFm at 5:00 am", rp, "YouFM", 5, rp.YouFMInfo[0]), + Arguments.of("Station info YouFm at 5:00 am", rp, "YouFM", 10, rp.YouFMInfo[1]), + Arguments.of("Station info YouFm at 5:00 am", rp, "YouFM", 14, rp.YouFMInfo[2]), + Arguments.of("Station info YouFm at 5:00 am", rp, "YouFM", 18, rp.YouFMInfo[3]), + Arguments.of("Station info YouFm at 5:00 am", rp, "YouFM", 20, rp.YouFMInfo[4]), + Arguments.of("Station info YouFm at 5:00 am", rp, "YouFM", 22, rp.YouFMInfo[5]), + Arguments.of("Station info YouFm at 5:00 am", rp, "YouFM", 3, rp.YouFMInfo[6]) + ); } @ParameterizedTest