Beispiel #1
0
 public void Card_NewCardWithSpecifiedOrientation_OrientationIsCorrect()
 {
     var card1 = new Card( 1, CardSuit.Spades, CardOrientation.FaceDown );
      Assert.AreEqual( CardOrientation.FaceDown, card1.Orientation );
      var card2 = new Card( 1, CardSuit.Spades, CardOrientation.FaceUp );
      Assert.AreEqual( CardOrientation.FaceUp, card2.Orientation );
 }
Beispiel #2
0
 public void RemoveCard_RemoveCard_ReturnsLastCardAdded()
 {
     var expected = new Card( CardRank.King, CardSuit.Spades );
      _pile.AddCard( expected );
      var actual = _pile.RemoveCard();
      Assert.AreEqual( actual, expected );
 }
Beispiel #3
0
 public void Card_NewCard_OrientationIsFaceDown()
 {
     var card1 = new Card( 1, CardSuit.Spades );
      Assert.AreEqual( CardOrientation.FaceDown, card1.Orientation );
      var card2 = new Card( CardRank.King, CardSuit.Spades );
      Assert.AreEqual( CardOrientation.FaceDown, card2.Orientation );
 }
Beispiel #4
0
 public bool IsOppositeColor( Card card )
 {
     if ( Color == card.Color )
      {
     return false;
      }
      return true;
 }
Beispiel #5
0
        public void Add( Card cardToAdd )
        {
            if ( cardToAdd == null )
             {
            throw new ArgumentNullException( "cardToAdd" );
             }

             _cards.Add( cardToAdd );
        }
 public FoundationPileTest()
 {
     _aceOfSpades = new Card( 1, CardSuit.Spades );
      _twoOfSpades = new Card( 2, CardSuit.Spades );
      _threeOfSpades = new Card( 3, CardSuit.Spades );
      _aceOfDiamonds = new Card( 1, CardSuit.Diamonds );
      _twoOfDiamonds = new Card( 2, CardSuit.Diamonds );
      _threeOfDiamonds = new Card( 3, CardSuit.Diamonds );
 }
 public TableauPileTest()
 {
     _kingOfSpades = new Card( 13, CardSuit.Spades );
      _queenOfSpades = new Card( 12, CardSuit.Spades );
      _kingOfDiamonds = new Card( 13, CardSuit.Diamonds );
      _queenOfDiamonds = new Card( 12, CardSuit.Diamonds );
      _jackOfSpades = new Card( 11, CardSuit.Spades );
      _jackOfDiamonds = new Card( 11, CardSuit.Diamonds );
 }
Beispiel #8
0
 public void Card_ConstructCard_ColorIsCorrect()
 {
     var card1 = new Card( 1, CardSuit.Spades );
      var card2 = new Card( 1, CardSuit.Clubs );
      var card3 = new Card( 1, CardSuit.Hearts );
      var card4 = new Card( 1, CardSuit.Diamonds );
      Assert.IsTrue( card1.Color == CardColor.Black );
      Assert.IsTrue( card2.Color == CardColor.Black );
      Assert.IsTrue( card3.Color == CardColor.Red );
      Assert.IsTrue( card4.Color == CardColor.Red );
 }
Beispiel #9
0
        public void AddCard( Card card )
        {
            if ( card == null )
             {
            throw new ArgumentNullException();
             }

             if ( ! CanAddCard( card ) )
             {
            throw new InvalidOperationException( "Can't add this card" );
             }

             _cards.Push( card );
        }
Beispiel #10
0
        public void Add_DeckIsEmpty_CardsAddedAreReturnedInOrder()
        {
            _deck.Deal( 52 );

             var card1ToAdd = new Card( CardRank.Ace, CardSuit.Spades );
             var card2ToAdd = new Card( CardRank.Two, CardSuit.Spades );
             var card3ToAdd = new Card( CardRank.Three, CardSuit.Spades );

             _deck.Add( card1ToAdd );
             _deck.Add( card2ToAdd );
             _deck.Add( card3ToAdd );

             var cards = _deck.Deal( 3 );

             Assert.AreEqual( card1ToAdd, cards[0] );
             Assert.AreEqual( card2ToAdd, cards[1] );
             Assert.AreEqual( card3ToAdd, cards[2] );
        }
Beispiel #11
0
        public IList<Card> Deal( int howManyToDeal = 1 )
        {
            if ( _cards.Count < howManyToDeal )
             {
            var msg = string.Format( "Asked for {0} card{1} but deck had {2}", howManyToDeal, howManyToDeal > 1 ? "s" : "", _cards.Count );
            throw new NotEnoughCardsException( msg );
             }

             if ( howManyToDeal < 0 )
             {
            throw new ArgumentException( "howManyToDeal" );
             }

             var cardsToReturn = new Card[howManyToDeal];

             if ( howManyToDeal > 0 )
             {
            _cards.CopyTo( 0, cardsToReturn, 0, howManyToDeal );
            _cards.RemoveRange( 0, howManyToDeal );
             }

             return cardsToReturn;
        }
Beispiel #12
0
        public void Card_ConstructCardVariousWays_CardIsCorrect()
        {
            var card1 = new Card( CardRank.Ace, CardSuit.Spades );
             var card2 = new Card( 2, CardSuit.Hearts );
             var card3 = new Card( CardRank.Three, CardSuit.Clubs );
             var card4 = new Card( 4, CardSuit.Diamonds );

             Assert.IsTrue( card1.Color == CardColor.Black );
             Assert.IsTrue( card1.Rank == CardRank.Ace );
             Assert.IsTrue( card1.Suit == CardSuit.Spades );

             Assert.IsTrue( card2.Color == CardColor.Red );
             Assert.IsTrue( card2.Rank == CardRank.Two );
             Assert.IsTrue( card2.Suit == CardSuit.Hearts );

             Assert.IsTrue( card3.Color == CardColor.Black );
             Assert.IsTrue( card3.Rank == CardRank.Three );
             Assert.IsTrue( card3.Suit == CardSuit.Clubs );

             Assert.IsTrue( card4.Color == CardColor.Red );
             Assert.IsTrue( card4.Rank == CardRank.Four );
             Assert.IsTrue( card4.Suit == CardSuit.Diamonds );
        }
Beispiel #13
0
        public void ValidClick(Card item)
        {
            if (item.Flipped == true && item.CurrentPile.stack.Peek() == item) {

            };
        }
Beispiel #14
0
 public void Card_ConstructWithRankGreaterThan13_ThrowsArgumentException()
 {
     var card = new Card( 14, CardSuit.Spades );
 }
Beispiel #15
0
 public void Card_ConstructWithRankLessThan1_ThrowsArgumentException()
 {
     var card = new Card( 0, CardSuit.Spades );
 }
Beispiel #16
0
 public virtual bool CanAddCard( Card card )
 {
     return true;
 }
Beispiel #17
0
 public void IsOppositeColor_CalledOnSameColor_ReturnsFalse()
 {
     var card1 = new Card( 1, CardSuit.Spades );
      var card2 = new Card( 1, CardSuit.Clubs );
      var card3 = new Card( 1, CardSuit.Hearts );
      var card4 = new Card( 1, CardSuit.Diamonds );
      Assert.IsFalse( card1.IsOppositeColor( card2 ) );
      Assert.IsFalse( card3.IsOppositeColor( card4 ) );
 }