From 7fbeacc0aa1dc5161da566c4a42ef8df3127bc8d Mon Sep 17 00:00:00 2001 From: fdai7920 Date: Fri, 19 Jan 2024 14:30:32 +0100 Subject: [PATCH] Test.CardsGetID --- .../java/de/hsfulda/onses/models/Cards.java | 19 +++++++++++-- src/test/java/de/hsfulda/onses/CardsTest.java | 28 +++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 src/test/java/de/hsfulda/onses/CardsTest.java diff --git a/src/main/java/de/hsfulda/onses/models/Cards.java b/src/main/java/de/hsfulda/onses/models/Cards.java index 59e5da4..e96f8f6 100644 --- a/src/main/java/de/hsfulda/onses/models/Cards.java +++ b/src/main/java/de/hsfulda/onses/models/Cards.java @@ -20,8 +20,21 @@ public class Cards { } }; - private int id; - private ecolor color; - private evalue value; + private final int id; + private final ecolor color; + private final evalue value; + + + public Cards(int id, ecolor color, evalue value) + { + this.id = id; + this.color = color; + this.value = value; + } + + + public int getId() { + return this.id; + } } diff --git a/src/test/java/de/hsfulda/onses/CardsTest.java b/src/test/java/de/hsfulda/onses/CardsTest.java new file mode 100644 index 0000000..d1d7daa --- /dev/null +++ b/src/test/java/de/hsfulda/onses/CardsTest.java @@ -0,0 +1,28 @@ + +package de.hsfulda.onses; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +import de.hsfulda.onses.models.Cards; + +public class CardsTest { + + @Test + @DisplayName("ModelCardsClass") + public void CardTestGetID5() { + + Cards testcard = new Cards(5, Cards.ecolor.BLACK, Cards.evalue.FIVE); + assertEquals(5, testcard.getId()); + } + @Test + @DisplayName("ModelCardsClass") + public void CardTestGetID112() { + + Cards testcard = new Cards(112, Cards.ecolor.BLUE, Cards.evalue.CHOOSEDRAW); + assertEquals(112, testcard.getId()); + } + + +} \ No newline at end of file