### Question:
CardDeckFactory { public CardDeck createDeck(int numberOfCards) { if (numberOfCards % 4 != 0 || numberOfCards < 4 || numberOfCards > 52) { throw new IllegalArgumentException("Number of Cards must be multipler of 4 between 4 and 52"); } int numberOfRanks = numberOfCards / 4; Set<Card> cards = new TreeSet<>(); for (SUIT suit : SUIT.values()){ for (int i = 0; i < numberOfRanks; i++){ cards.add(aCard(suit, RANK.values()[i])); } } return new CardDeck(cards); }  CardDeck createDeck(int numberOfCards);  }### Answer:
@Test public void aDeckCannotANotAMultiplierOf4(){ Assertions.assertThatThrownBy(() -> factory.createDeck(5)) .isInstanceOf(IllegalArgumentException.class); }
@Test public void aDeckOf0CardsDoesNotExist(){ Assertions.assertThatThrownBy(() -> factory.createDeck(0)) .isInstanceOf(IllegalArgumentException.class); }
@Test public void aDeckCannotConsistsOfMoreThen13Ranks(){ Assertions.assertThatThrownBy(() -> factory.createDeck(53)) .isInstanceOf(IllegalArgumentException.class); }
@Test public void aDeckOf4CardsHas4DifferentAcesOnly(){ CardDeck cardDeck = factory.createDeck(4); Set<Card> cards = cardDeck.getRemainingCards(); assertThat(cards) .hasSize(4) .contains(aCard(SUIT.HEART, RANK.ACE), aCard(SUIT.DIAMOND, RANK.ACE), aCard(SUIT.CLUB, RANK.ACE), aCard(SUIT.SPADE, RANK.ACE)); }
@Test public void aDeckOf8CardsHas4DifferentAcesAndKindsOnly(){ CardDeck cardDeck = factory.createDeck(8); Set<Card> cards = cardDeck.getRemainingCards(); assertThat(cards) .hasSize(8) .contains(aCard(SUIT.HEART, RANK.ACE), aCard(SUIT.DIAMOND, RANK.ACE), aCard(SUIT.CLUB, RANK.ACE), aCard(SUIT.SPADE, RANK.ACE), aCard(SUIT.HEART, RANK.KING), aCard(SUIT.DIAMOND, RANK.KING), aCard(SUIT.CLUB, RANK.KING), aCard(SUIT.SPADE, RANK.KING)); }
@Test public void aDeckOf52CardsHasAll13Ranks(){ CardDeck cardDeck = factory.createDeck(52); Set<Card> cards = cardDeck.getRemainingCards(); assertThat(cards) .hasSize(52) .contains(aCard(SUIT.HEART, RANK.ACE), aCard(SUIT.DIAMOND, RANK.ACE), aCard(SUIT.CLUB, RANK.ACE), aCard(SUIT.SPADE, RANK.TWO)); }