Пример #1
0
 public void ShouldReturnSuitExpectedRankingForEveryPermutation()
 {
     ISuit[] suits =
     {
         Suit.Club,
         Suit.Diamond,
         Suit.Heart,
         Suit.Spade
     };
     for (int thisIdx = 0; thisIdx < suits.Length; thisIdx++)
     {
         for (int otherIdx = 0; otherIdx < suits.Length; otherIdx++)
         {
             IValueCompare compare = suits[thisIdx].Compare(suits[otherIdx]);
             if (thisIdx == otherIdx)
             {
                 compare.IsEqual().Should().BeTrue();
                 compare.IsLesser().Should().BeFalse();
                 compare.IsGreater().Should().BeFalse();
             }
             if (thisIdx < otherIdx)
             {
                 compare.IsEqual().Should().BeFalse();
                 compare.IsLesser().Should().BeTrue();
                 compare.IsGreater().Should().BeFalse();
             }
             if (thisIdx > otherIdx)
             {
                 compare.IsEqual().Should().BeFalse();
                 compare.IsLesser().Should().BeFalse();
                 compare.IsGreater().Should().BeTrue();
             }
         }
     }
 }
Пример #2
0
 public void ShouldReturnExpectedSuitRankingForEveryPermutation()
 {
     ICard[] suits =
     {
         new Card(Suit.Club),
         new Card(Suit.Diamond),
         new Card(Suit.Heart),
         new Card(Suit.Spade)
     };
     for (int thisIdx = 0; thisIdx < suits.Length; thisIdx++)
     {
         for (int otherIdx = 0; otherIdx < suits.Length; otherIdx++)
         {
             IValueCompare compare = suits[thisIdx].Compare(suits[otherIdx]);
             if (thisIdx == otherIdx)
             {
                 compare.IsEqual().Should().BeTrue();
                 compare.IsLesser().Should().BeFalse();
             }
             if (thisIdx < otherIdx)
             {
                 compare.IsEqual().Should().BeFalse();
                 compare.IsLesser().Should().BeTrue();
             }
             if (thisIdx > otherIdx)
             {
                 compare.IsEqual().Should().BeFalse();
                 compare.IsLesser().Should().BeFalse();
             }
         }
     }
 }
Пример #3
0
 public void ShouldReturnExpectedRankRankingForEveryPermutation()
 {
     ICard[] ranks =
     {
         new Card(Suit.Club, Rank.Two),
         new Card(Suit.Club, Rank.Three),
         new Card(Suit.Club, Rank.Four),
         new Card(Suit.Club, Rank.Five),
         new Card(Suit.Club, Rank.Six),
         new Card(Suit.Club, Rank.Seven),
         new Card(Suit.Club, Rank.Eight),
         new Card(Suit.Club, Rank.Nine),
         new Card(Suit.Club, Rank.Ten),
         new Card(Suit.Club, Rank.Jack),
         new Card(Suit.Club, Rank.Queen),
         new Card(Suit.Club, Rank.King),
         new Card(Suit.Club, Rank.Ace)
     };
     for (int thisIdx = 0; thisIdx < ranks.Length; thisIdx++)
     {
         for (int otherIdx = 0; otherIdx < ranks.Length; otherIdx++)
         {
             IValueCompare compare = ranks[thisIdx].Compare(ranks[otherIdx]);
             if (thisIdx == otherIdx)
             {
                 compare.IsEqual().Should().BeTrue();
                 compare.IsLesser().Should().BeFalse();
                 compare.IsGreater().Should().BeFalse();
             }
             if (thisIdx < otherIdx)
             {
                 compare.IsEqual().Should().BeFalse();
                 compare.IsLesser().Should().BeTrue();
                 compare.IsGreater().Should().BeFalse();
             }
             if (thisIdx > otherIdx)
             {
                 compare.IsEqual().Should().BeFalse();
                 compare.IsLesser().Should().BeFalse();
                 compare.IsGreater().Should().BeTrue();
             }
         }
     }
 }
Пример #4
0
        public void ShouldReturnFalseGivenSameCard()
        {
            //Arrange
            ICard card = new Card(Suit.Club);

            //Act
            IValueCompare compared = card.Compare(card);

            //Assert
            compared.IsEqual().Should().BeTrue();
        }
Пример #5
0
        public IValueCompare Compare(ICard other)
        {
            //Todo Chain?
            IValueCompare otherRankCompare = other.Compare(_rank);

            if (otherRankCompare.IsEqual())
            {
                return(other.Compare(_suit));
            }
            return(new NegateValueCompare(otherRankCompare));
        }