public void Can_Draw_A_Card() { var sut = new StandardDeck(); Assert.DoesNotThrow(() => { var card = sut.Draw(); Assert.IsNotNull(card); }); var cardCount = sut.Cards.Count; for (var i = 0; i < cardCount; i++) { sut.Draw(); } Assert.Throws <InvalidOperationException>(() => { sut.Draw(); }); }
public void Can_Deal_Cards() { var sut = new StandardDeck(); //throws if more than the cards in deck Assert.Throws <InvalidOperationException>(() => { sut.Deal(new DealingOptions { Groups = 1, CardsPerGroup = 100 }); }); sut = new StandardDeck(); //does not throw if more than the cards in deck Assert.DoesNotThrow(() => { sut.Deal(new DealingOptions { Groups = 1, CardsPerGroup = 100, AsEvenPiles = false }); }); sut = new StandardDeck(); var newSetOfCards = new StandardDeck(); var result = sut.Deal(new DealingOptions { Groups = 3, CardsPerGroup = 5 }).ToList(); var player1ExpectedCards = new List <ICard> { newSetOfCards.Draw(), newSetOfCards.Draw(), newSetOfCards.Draw(), newSetOfCards.Draw(), newSetOfCards.Draw() }; var player2ExpectedCards = new List <ICard> { newSetOfCards.Draw(), newSetOfCards.Draw(), newSetOfCards.Draw(), newSetOfCards.Draw(), newSetOfCards.Draw() }; var player3ExpectedCards = new List <ICard> { newSetOfCards.Draw(), newSetOfCards.Draw(), newSetOfCards.Draw(), newSetOfCards.Draw(), newSetOfCards.Draw() }; var dealtPile1 = result.ElementAt(0).ToList(); Assert.AreEqual(player1ExpectedCards.Count, dealtPile1.Count); foreach (var card in player1ExpectedCards) { Assert.IsTrue(dealtPile1.ContainsCard(card)); } var dealtPile2 = result.ElementAt(1).ToList(); Assert.AreEqual(player2ExpectedCards.Count, dealtPile2.Count); foreach (var card in player2ExpectedCards) { Assert.IsTrue(dealtPile2.ContainsCard(card)); } var dealtPile3 = result.ElementAt(2).ToList(); Assert.AreEqual(player3ExpectedCards.Count, dealtPile3.Count); foreach (var card in player3ExpectedCards) { Assert.IsTrue(dealtPile3.ContainsCard(card)); } }