public void PlayShouldCallGetTurnAndEndTurnForBothPlayers()
        {
            var firstPlayer = new ValidPlayer();
            var firstPlayerInfo = new RoundPlayerInfo(firstPlayer);
            var secondPlayer = new ValidPlayer();
            var secondPlayerInfo = new RoundPlayerInfo(secondPlayer);
            var stateManager = new StateManager();
            var deck = new Deck();

            SimulateGame(firstPlayerInfo, secondPlayerInfo, deck);

            var trick = new Trick(firstPlayerInfo, secondPlayerInfo, stateManager, deck, GameRulesProvider.Santase);
            var winner = trick.Play();

            Assert.AreEqual(1, firstPlayer.GetTurnCalledCount);
            Assert.AreEqual(1, secondPlayer.GetTurnCalledCount);
            Assert.AreEqual(1, firstPlayer.EndTurnCalledCount);
            Assert.AreEqual(1, secondPlayer.EndTurnCalledCount);

            Assert.IsNotNull(firstPlayer.GetTurnContextObject);
            Assert.IsNotNull(secondPlayer.GetTurnContextObject);
            Assert.IsNotNull(firstPlayer.EndTurnContextObject);
            Assert.IsNotNull(secondPlayer.EndTurnContextObject);

            Assert.IsNotNull(firstPlayer.EndTurnContextObject.FirstPlayedCard);
            Assert.IsNotNull(firstPlayer.EndTurnContextObject.SecondPlayedCard);
            Assert.IsNotNull(secondPlayer.EndTurnContextObject.FirstPlayedCard);
            Assert.IsNotNull(secondPlayer.EndTurnContextObject.SecondPlayedCard);

            Assert.IsTrue(winner == firstPlayerInfo || winner == secondPlayerInfo);
        }
Example #2
0
 public void DeckTestGetNextCardShouldReturnValidCard()
 {
     var deck = new Deck();
     var card = deck.GetNextCard();
     Assert.IsTrue(Enum.IsDefined(typeof(CardSuit), card.Suit), "Invalid card suit: " + deck.GetTrumpCard.Suit.ToString());
     Assert.IsTrue(Enum.IsDefined(typeof(CardType), card.Type), "Invalid card type: " + deck.GetTrumpCard.Type.ToString());
 }
 public void ChangingTrumpCardShouldNotThrow()
 {
     Deck deck = new Deck();
     Card trumpCard = deck.GetTrumpCard;
     Card newCard = new Card(CardSuit.Heart, CardType.Nine);
     deck.ChangeTrumpCard(newCard);
 }
Example #4
0
 public void TestsIfCardRemovalWorks()
 {
     Deck testDeck = new Deck();
     int initialCardsCount = testDeck.CardsLeft;
     testDeck.GetNextCard();
     Assert.AreEqual((initialCardsCount - 1), testDeck.CardsLeft, "GetNextCard() should remove 1 card from the deck");
 }
 public void TestDeckChangeTrumpCard()
 {
     var card = new Card(CardSuit.Club, CardType.Jack);
     var deck = new Santase.Logic.Cards.Deck();
     deck.ChangeTrumpCard(card);
     Assert.AreEqual(card, deck.GetTrumpCard);
 }
 public void ExpectTrumpCardToBeCorrectAfterAChange()
 {
     var deck = new Deck();
     var trumpCard = deck.GetNextCard();
     deck.ChangeTrumpCard(trumpCard);
     Assert.AreSame(deck.GetTrumpCard, trumpCard);
 }
 public void ExpectTrumpCardToEqualSwappedCard()
 {
     var deck = new Deck();
     var card = new Card(CardSuit.Club, CardType.Ace);
     deck.ChangeTrumpCard(card);
     Assert.AreEqual(card, deck.GetTrumpCard);
 }
Example #8
0
        public void TestDeckGetNextCard()
        {
            var deck = new Santase.Logic.Cards.Deck();
            var card = deck.GetNextCard();

            Assert.AreEqual(23, deck.CardsLeft);
        }
Example #9
0
 public void DeckTestGetNextCard25TimesShouldThrow()
 {
     var deck = new Deck();
     for (int i = 0; i < cardsCount + 1; i++)
     {
         var card = deck.GetNextCard();
     }
 }
Example #10
0
 public void GetNextCardShouldNotChangeTheTrumpCard()
 {
     IDeck deck = new Deck();
     var trumpBefore = deck.TrumpCard;
     deck.GetNextCard();
     var trumpAfter = deck.TrumpCard;
     Assert.AreEqual(trumpBefore, trumpAfter);
 }
Example #11
0
 public void ChangeTrumpCardShouldWorkProperly()
 {
     IDeck deck = new Deck();
     var card = new Card(CardSuit.Spade, CardType.Nine);
     deck.ChangeTrumpCard(card);
     var trumpCard = deck.TrumpCard;
     Assert.AreEqual(card, trumpCard);
 }
 public void DeckShouldThrowAnExceptionWhenDrawingMoreCardsThanInTheDeck()
 {
     var deck = new Deck();
     for (int i = 1; i <= 25; i++)
     {
         deck.GetNextCard();
     }
 }
Example #13
0
 public void TestNextCardGotFromTheDeckIsNotNull()
 {
     Deck gameDeck = new Deck();
     int initialCardsCount = gameDeck.CardsLeft;
     Assert.Greater(initialCardsCount, 0);
     Card nextCard = gameDeck.GetNextCard();
     Assert.IsNotNull(nextCard);
 }
Example #14
0
 public void ChangeTrumpCardShouldChangeTheTrumpCardIfThereAreCardsLeftInTheDeck()
 {
     Deck testDeck = new Deck();
     Card initialTrumpCard = testDeck.GetTrumpCard;
     Card newCard = testDeck.GetNextCard();
     testDeck.ChangeTrumpCard(newCard);
     Assert.AreNotSame(initialTrumpCard, testDeck.GetTrumpCard);
 }
Example #15
0
        public void TestChangeWtihDifferentTrumps(string patternForCard)
        {
            Deck cards = new Deck();
            Card trump = GenerateCard(patternForCard);
            cards.ChangeTrumpCard(trump);

            Assert.AreEqual(trump.Type.ToFriendlyString() + trump.Suit.ToFriendlyString(), cards.GetTrumpCard.ToString());
        }
 public void TestDeckGetNextCardWhenDeckIsEmpty(int count)
 {
     var deck = new Santase.Logic.Cards.Deck();
     for (int i = 0; i < count; i++)
     {
         var card = deck.GetNextCard();
     }
 }
Example #17
0
 public void GetNextCardShouldThrowExceptionIfGetNextCardIsCalledMoreThanTheNumberOfCardsInDeck()
 {
     var deck = new Deck();
     for (int i = 0; i <= CardsCount; i++)
     {
         deck.GetNextCard();
     }
 }
        public void TestGetNextCardShouldRemoveTheCardFromTheDeck()
        {
            Deck deck = new Deck();
            int initialNumberOfCards = deck.CardsLeft;
            deck.GetNextCard();

            Assert.AreEqual((initialNumberOfCards - 1), deck.CardsLeft, "GetNextCard() should remove 1 card from the deck");
        }
 public void GetNextCardThrowsAfterTakeCardFromEmptyDeck(int count)
 {
     var deck = new Deck();
     for (int i = 0; i < count; i++)
     {
         deck.GetNextCard();
     }
 }
 public void ExpectGetNextCardToThrowWhenDrawingMoreThanTheDeckSize()
 {
     var deck = new Deck();
     for (int i = 0; i < 25; i++)
     {
         var card = deck.GetNextCard();
     }
 }
Example #21
0
 public void GetNextCardShouldThrowAnInternalGameExceptionWhenThereAreNoCardsLeftInTheDeck(int cardsToBeDrawn)
 {
     Deck testDeck = new Deck();
     for (int i = 0; i < cardsToBeDrawn; i++)
     {
         testDeck.GetNextCard();
     }
 }
 public void DeckShouldReturnProperTrumpCardAfterChangingIt()
 {
     var deck = new Deck();
     var newTrumpCard = new Card(CardSuit.Heart, CardType.Ace);
     deck.ChangeTrumpCard(newTrumpCard);
     var currentTrumpCard = deck.GetTrumpCard;
     Assert.AreSame(newTrumpCard, currentTrumpCard);
 }
Example #23
0
        public void TestDeckChangeTrumpCard()
        {
            var card = new Card(CardSuit.Club, CardType.Jack);
            var deck = new Santase.Logic.Cards.Deck();

            deck.ChangeTrumpCard(card);
            Assert.AreEqual(card, deck.GetTrumpCard);
        }
        public void DeckShouldThrowWhenNextCardIsNotPresent()
        {
            Deck deck = new Deck();

            for (int i = 0; i < InitialDeckCardsCount + 1; i++)
            {
                deck.GetNextCard();
            }
        }
Example #25
0
        public void DrawNextCardOnEmptyDeck_ShouldThrowException()
        {
            var deck = new Deck();

            for (int card = 0; card <= DeckSize; card++)
            {
                deck.GetNextCard();
            }
        }
Example #26
0
        public void ChangeTrumpCardChangesItSuccessfully()
        {
            var deck = new Deck();
            var trumpCard = deck.GetTrumpCard;
            deck.ChangeTrumpCard(new Card(CardSuit.Club, CardType.Ace));
            var changedTrumpCard = deck.GetTrumpCard;

            Assert.AreNotEqual(trumpCard, changedTrumpCard, "Trump cards are the same! Rerun test if by chance the original trump card was the same as the new one!");
        }
Example #27
0
        public void CreatingNewDeckAndChangingDefaultTrumpCardWithTheSameTrumpCardShouldReturnTheSameTrumpCard()
        {
            var deck = new Deck();
            var trumpCard = deck.GetTrumpCard;

            deck.ChangeTrumpCard(trumpCard);

            Assert.AreSame(trumpCard, deck.GetTrumpCard);
        }
Example #28
0
 public void DrawNextCardFromEmptyDeckShouldThrowException(int cardsToBeDrawn)
 {
     var deck = new Deck();
     for (int i = 0; i < cardsToBeDrawn; i++)
     {
         deck.GetNextCard();
     }
     Assert.Throws<InternalGameException>(() => deck.GetNextCard());
 }
        public void ThrowExceptionOnGettingNextCartOnEmptyDeck()
        {
            Deck deck = new Deck();

            for (int i = 0; i <= 24; i++)
            {
                deck.GetNextCard();
            }
        }
Example #30
0
        public void CreatingNewDeckAndGettingMoreThan24NextCardsShouldThrowAnException(int countOfCards)
        {
            var deck = new Deck();

            for (int i = 0; i < countOfCards; i++)
            {
                var nextCard = deck.GetNextCard();
            }
        }
Example #31
0
        public void TestDeckGetNextCardWhenDeckIsEmpty(int count)
        {
            var deck = new Santase.Logic.Cards.Deck();

            for (int i = 0; i < count; i++)
            {
                var card = deck.GetNextCard();
            }
        }
        public void DeckShouldChangeTrumpCardCorrectly()
        {
            Deck deck = new Deck();
            Card newTrumpCard = new Card(CardSuit.Spade, CardType.Ace);

            deck.ChangeTrumpCard(newTrumpCard);

            Assert.AreEqual(newTrumpCard, deck.GetTrumpCard);
        }
        public void DrawNextCardOnEmptyDeckShouldThrow()
        {
            var deck = new Deck();

            for (int card = 0; card <= 24; card++)
            {
                deck.GetNextCard();
            }
        }
Example #34
0
        public void TestDeckCtorWithInvalidCardsCount(int cardsCount)
        {
            var deck = new Santase.Logic.Cards.Deck();

            if (cardsCount == 24)
            {
                Assert.AreEqual(cardsCount, deck.CardsLeft);
            }
            else
            {
                Assert.AreNotEqual(cardsCount, deck.CardsLeft);
            }
        }