You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
package solitaer;
import static org.junit.jupiter.api.Assertions.*;
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() { int result = deck.getDeck().size(); assertEquals(52, result, "Kartendeck muss genau 52 Carden haben") ;
} @ParameterizedTest @MethodSource("testSymbole") //Jedes Symbol muss einmal vorhand sein
void testCardDeckSymbole(String _msg, Symbol _sym) { boolean result = false; for(int allCardZähler = 0; allCardZähler<deck.getDeck().size(); allCardZähler++) { if(deck.getDeck().get(allCardZähler).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) ); } @Test //Jedes Symbol muss 13 mal vorrhanden sein
void testCardDeckNumber() { boolean result = true; result = CheckAllCards(Symbol.Herz) && CheckAllCards(Symbol.Karo) && CheckAllCards(Symbol.Kreuz) && CheckAllCards(Symbol.Pik); assertTrue(result); }
private boolean CheckAllCards(Symbol _sym) { boolean result = true; for(int nrZähler =1; nrZähler<=13; nrZähler++) { if(deck.getDeck().contains(new Card(nrZähler, _sym, false))== false) { result = false; break; } } return result; }
}
|