From 2ef4c3f5844032d72cae5804e3e1660e1e1cd671 Mon Sep 17 00:00:00 2001 From: Andrin Fassbind Date: Fri, 13 May 2022 21:46:31 +0200 Subject: [PATCH] create PlayerTest --- .../LanguageConfigurator.java | 3 -- app/src/test/java/PlayerTest.java | 40 +++++++++++++++++++ .../turnierverwaltung/LanguageTest.java | 18 +++++++++ 3 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 app/src/test/java/PlayerTest.java create mode 100644 app/src/test/java/ch/zhaw/projekt2/turnierverwaltung/LanguageTest.java diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/LanguageConfigurator.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/LanguageConfigurator.java index 396fa7c..a97b044 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/LanguageConfigurator.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/LanguageConfigurator.java @@ -103,11 +103,9 @@ public class LanguageConfigurator { englishDictionary.put("participantNotExist","Participant does not exist"); germanDictionary.put("placeNotExist","Teilnehmer existiert nicht"); englishDictionary.put("placeNotExist","Participant does not exist"); - //SaveMsg germanDictionary.put("save","Zuletzt gespeichert: "); englishDictionary.put("save","Last saved: "); - //Alert germanDictionary.put("yes","Ja"); englishDictionary.put("yes","Yes"); @@ -119,7 +117,6 @@ public class LanguageConfigurator { englishDictionary.put("headerDelete","Delete Tournament?"); germanDictionary.put("contentDelete","Sind Sie sicher, dass sie das Turnier entfernen wollen?\nNach diesem Vorgang kann es nicht wiederhergestellt werden."); englishDictionary.put("contentDelete","Are you shure you want to delete the tournament?\nAfter that there is no way to restore."); - germanDictionary.put("titleSchedule","Neu erstellen"); englishDictionary.put("titleSchedule","Create new"); germanDictionary.put("headerSchedule","Spielplan neu erstellen?"); diff --git a/app/src/test/java/PlayerTest.java b/app/src/test/java/PlayerTest.java new file mode 100644 index 0000000..3003af4 --- /dev/null +++ b/app/src/test/java/PlayerTest.java @@ -0,0 +1,40 @@ +import ch.zhaw.projekt2.turnierverwaltung.InvalidNameException; +import ch.zhaw.projekt2.turnierverwaltung.Person; +import ch.zhaw.projekt2.turnierverwaltung.Player; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class PlayerTest { + private Player player; + + @Test + @DisplayName("Test invalid Parameter") + void invalidParams() { + try { + assertThrows(Person.InvalidPhoneNumberException.class,()->new Player("A","a",".sad","")); + assertThrows(Player.InvalidDateException.class,()->new Player("A","a","","a")); + player = new Player("A","A","",""); + assertEquals("A",player.getFirstName()); + assertEquals("A",player.getName()); + assertEquals("",player.getPhoneNumber()); + assertNull(player.getDateOfBirth()); + } catch (InvalidNameException | Person.InvalidPhoneNumberException | Player.InvalidDateException e) { + fail(); + } + } + + @Test + @DisplayName("Test equals") + void equalsTest() { + try { + player = new Player("A","A","",""); + assertTrue(player.equals(player)); + assertFalse(player.equals(new Player("B", "D", "", ""))); + assertTrue(player.equals(new Player("A", "A", "", ""))); + } catch (InvalidNameException | Person.InvalidPhoneNumberException | Player.InvalidDateException e) { + e.printStackTrace(); + } + } +} diff --git a/app/src/test/java/ch/zhaw/projekt2/turnierverwaltung/LanguageTest.java b/app/src/test/java/ch/zhaw/projekt2/turnierverwaltung/LanguageTest.java new file mode 100644 index 0000000..e5dfdb8 --- /dev/null +++ b/app/src/test/java/ch/zhaw/projekt2/turnierverwaltung/LanguageTest.java @@ -0,0 +1,18 @@ +package ch.zhaw.projekt2.turnierverwaltung; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +public class LanguageTest { + + @Test + @DisplayName("Test Dictionary") + void test() { + LanguageConfigurator languageConfigurator = new LanguageConfigurator(); + Assertions.assertEquals("Ja",languageConfigurator.getSelectedLanguage("yes")); + languageConfigurator.changeLanguage(LanguageConfigurator.Language.ENGLISH); + Assertions.assertEquals("Yes",languageConfigurator.getSelectedLanguage("yes")); + + } +}