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:
Dave Burke
2022-02-07 15:02:13 -06:00
parent 15c26cbe09
commit 0b1f57ae4f
5 changed files with 345 additions and 250 deletions

View File

@@ -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();