mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-23 07:29:02 -08:00
Refactor to allow testing side effects
By externalizing the source of i/o and randomness for shuffling, we can inject non-interactive and deterministic behavior during unit tests.
This commit is contained in:
@@ -7,7 +7,8 @@ public class DeckTest {
|
||||
@Test
|
||||
void testInit() {
|
||||
// When
|
||||
Deck deck = new Deck();
|
||||
Deck deck = new Deck((cards) -> cards);
|
||||
deck.reshuffle();
|
||||
|
||||
// Then
|
||||
long nCards = deck.size();
|
||||
|
||||
Reference in New Issue
Block a user