From f5fa33e182fc862c74d00d2065db1213a66c399f Mon Sep 17 00:00:00 2001 From: Caro Date: Sun, 16 Jun 2024 14:37:23 +0200 Subject: [PATCH] =?UTF-8?q?Test=20f=C3=BCr=20Reiseplanung?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TravelBuddyApp/.classpath | 1 + .../test/java/domain/ReiseplanungTest.java | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 TravelBuddyApp/src/test/java/domain/ReiseplanungTest.java diff --git a/TravelBuddyApp/.classpath b/TravelBuddyApp/.classpath index d2a08eb..373e075 100644 --- a/TravelBuddyApp/.classpath +++ b/TravelBuddyApp/.classpath @@ -36,5 +36,6 @@ + diff --git a/TravelBuddyApp/src/test/java/domain/ReiseplanungTest.java b/TravelBuddyApp/src/test/java/domain/ReiseplanungTest.java new file mode 100644 index 0000000..3a693ae --- /dev/null +++ b/TravelBuddyApp/src/test/java/domain/ReiseplanungTest.java @@ -0,0 +1,40 @@ +package domain; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +public class ReiseplanungTest { + + Auto auto = new Auto("Brummi", 167.6); + Ort ort = new Ort(1067, "Dresden", 13.7210676148814, 51.0600336463379); + User user = new User("Karl", "hallo", ort, auto, 30, 15); + Ort ziel = new Ort(1705, "Freital", 13.6382950999229, 50.9981963286759); + Reiseplanung reise = new Reiseplanung(user,ziel); + + + @Test + public void testBerechneEntfernung() { + + double result = reise.berechneEntfernung(ort, ziel); + + assertEquals(14.2125, result, 0.0); + } + + @Test + public void testBerechneDauer() { + double entfernung = 136.5; + double geschwindigkeit = 70; + + double result = reise.berechneDauer(entfernung, geschwindigkeit); + + assertEquals(1.95, result, 0.0); + } + + public void testBerechneCO2Ausstoß() { + double entfernung = 73.8; + + double result = reise.berechneCO2Ausstoß(entfernung, auto); + + assertEquals(12368.88, result, 0.0); + } +}