Alexander Hartung
3 years ago
3 changed files with 79 additions and 12 deletions
-
23src/main/java/solitaer/Card.java
-
29src/main/java/solitaer/CardDeck.java
-
39src/test/java/solitaer/CardDeckTest.java
@ -1,21 +1,54 @@ |
|||
package solitaer; |
|||
|
|||
import static org.junit.jupiter.api.Assertions.*; |
|||
import static org.mockito.Mockito.verify; |
|||
|
|||
import java.util.stream.Stream; |
|||
|
|||
import org.junit.jupiter.api.Test; |
|||
import org.junit.jupiter.params.ParameterizedTest; |
|||
import org.junit.jupiter.params.provider.Arguments; |
|||
import org.junit.jupiter.params.provider.MethodSource; |
|||
|
|||
class CardDeckTest { |
|||
|
|||
private CardDeck deck = new CardDeck(); |
|||
|
|||
@Test |
|||
void testCardDeckSize() { |
|||
CardDeck deck = new CardDeck(); |
|||
|
|||
void testCardDeckSize() { |
|||
int result = deck.getDeck().size(); |
|||
|
|||
assertEquals(52, result, "Kartendeck muss genau 52 Carden haben") ; |
|||
|
|||
} |
|||
|
|||
|
|||
@ParameterizedTest |
|||
@MethodSource("testSymbole") |
|||
void testCardDeckSymbole(String msg, Symbol _sym) { |
|||
|
|||
boolean result = false; |
|||
|
|||
for(int i = 0; i<deck.getDeck().size(); i++) { |
|||
if(deck.getDeck().get(i).getSymbol() == _sym) { |
|||
result = true; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
assertTrue(result, msg); |
|||
} |
|||
|
|||
|
|||
private static Stream<Arguments> testSymbole(){ |
|||
return Stream.of( |
|||
Arguments.of("Herz", Symbol.Herz), |
|||
Arguments.of("Karo", Symbol.Karo), |
|||
Arguments.of("Pik", Symbol.Pik), |
|||
Arguments.of("Kreuz",Symbol.Kreuz) |
|||
); |
|||
|
|||
|
|||
} |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue