当前位置: 首页>>代码示例>>C#>>正文


C# Card.CompareTo方法代码示例

本文整理汇总了C#中Card.CompareTo方法的典型用法代码示例。如果您正苦于以下问题:C# Card.CompareTo方法的具体用法?C# Card.CompareTo怎么用?C# Card.CompareTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Card的用法示例。


在下文中一共展示了Card.CompareTo方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestSortCards

 public void TestSortCards()
 {
     Card testAS = new Card(1, Suit.Spades);
     Card testKS = new Card(13, Suit.Spades);
     Card testQS = new Card(12, Suit.Spades);
     List<Card> cards = new List<Card>() { testAS, testQS, testKS };
     cards.Sort();
     Assert.IsTrue(testAS.CompareTo(testKS) > 0);
     Assert.IsFalse(testKS.CompareTo(testAS) > 0);
     Assert.IsTrue(testAS.CompareTo(testQS) > 0);
     Assert.IsFalse(testQS.CompareTo(testAS) > 0);
     Assert.IsTrue(testKS.CompareTo(testQS) > 0);
     Assert.IsFalse(testQS.CompareTo(testKS) > 0);
 }
开发者ID:shahboura,项目名称:Tarneeb,代码行数:14,代码来源:ShufflerTest.cs

示例2: TestCardSort

		public void TestCardSort(string first, string second, int expectedDifference)
		{
			var firstCard = new Card(first);
			var secondCard = new Card(second);

			var result = firstCard.CompareTo(secondCard);

			Assert.AreEqual(expectedDifference, result);
		}
开发者ID:droach282,项目名称:kata-pokerhands,代码行数:9,代码来源:CardTests.cs

示例3: TestCardCompareJackClubsWithJackHearts

        public void TestCardCompareJackClubsWithJackHearts()
        {
            Card jackClubs = new Card(CardFace.Jack, CardSuit.Clubs);
            Card jackHearts = new Card(CardFace.Jack, CardSuit.Hearts);

            int expected = -2;
            int actual = jackClubs.CompareTo(jackHearts);
            Assert.AreEqual(expected, actual);
        }
开发者ID:nkolarov,项目名称:telerik-academy,代码行数:9,代码来源:CardTests.cs

示例4: TestCardCompareAceWithJack

        public void TestCardCompareAceWithJack()
        {
            Card ace = new Card(CardFace.Ace, CardSuit.Hearts);
            Card jack = new Card(CardFace.Jack, CardSuit.Hearts);

            int expected = 3;
            int actual = ace.CompareTo(jack);
            Assert.AreEqual(expected, actual);
        }
开发者ID:nkolarov,项目名称:telerik-academy,代码行数:9,代码来源:CardTests.cs

示例5: TestCardCompareAceHeartsWithAceHearts

        public void TestCardCompareAceHeartsWithAceHearts()
        {
            Card aceHearts = new Card(CardFace.Ace, CardSuit.Hearts);
            Card anotherAceHearts = new Card(CardFace.Ace, CardSuit.Hearts);

            int expected = 0;
            int actual = aceHearts.CompareTo(anotherAceHearts);
            Assert.AreEqual(expected, actual);
        }
开发者ID:nkolarov,项目名称:telerik-academy,代码行数:9,代码来源:CardTests.cs

示例6: ShouldPassCompareToOffToItsIGame

        public void ShouldPassCompareToOffToItsIGame()
        {
            game.Expect(g => g.Compare(null, null)).IgnoreArguments().Return(0);

            var card1 = new Card(game) { Suit = "Clubs", Value = "5" };
            var card2 = new Card(game) { Suit = "Clubs", Value = "5" };
            card1.CompareTo(card2).ShouldBe(0);

            game.AssertWasCalled(g => g.Compare(card1, card2), mo => mo.IgnoreArguments());
        }
开发者ID:trayburn,项目名称:GameFramework,代码行数:10,代码来源:CardTest.cs

示例7: CompareToTest

 public void CompareToTest()
 {
     IComparable target = new Card(); // TODO: Initialize to an appropriate value
     object obj = null; // TODO: Initialize to an appropriate value
     int expected = 0; // TODO: Initialize to an appropriate value
     int actual;
     actual = target.CompareTo(obj);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
开发者ID:Twistie,项目名称:TwoServer,代码行数:10,代码来源:CardTest.cs

示例8: CompareCards

 private int CompareCards(Card card1, Card card2)
 {
     Suit tempTrump = trumpSuit;
     if (trumpSuit == Suit.None)
     {
         //Handle no trump
         trumpSuit = CurrentTrickBaseSuit;
     }
     if (card2.Suit != tempTrump && card1.Suit != tempTrump)
     {
         return 0;
     }
     else if (card2.Suit != tempTrump && card1.Suit == tempTrump)
     {
         return 1;
     }
     else if (card1.Suit != tempTrump && card2.Suit != tempTrump)
     {
         return -1;
     }
     else
     {
         return card1.CompareTo(card2);
     }
 }
开发者ID:shahboura,项目名称:Tarneeb,代码行数:25,代码来源:GamePlay.cs

示例9: CompareToTest

 public void CompareToTest()
 {
     var newCard = new Card(123, 123, "Name");
     Assert.AreEqual(newCard.CompareTo(_card), 0, "CompareTo broke");
 }
开发者ID:NidentalEgor,项目名称:CSharp,代码行数:5,代码来源:UnitTest.cs

示例10: TestCardComparison_LowToHigh

        public void TestCardComparison_LowToHigh()
        {
            List<Card> deck = DeckOfCards.GetPokerDeck();

            Card lowCard = new Card { rank = Rank.Deuce, suit = Suit.Diamonds };
            Card highCard = new Card { rank = Rank.Ten, suit = Suit.Clubs };

            string actual = string.Format("{0} is {1} {2}", lowCard.ToString(),
               lowCard.CompareTo(highCard) == -1 ? "lower than" : lowCard.CompareTo(highCard) == 1 ? "higher than"
               : "the same as", highCard.ToString());

            string expected = "Deuce of Diamonds is lower than Ten of Clubs";
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
开发者ID:iranye,项目名称:WorkingProjects,代码行数:14,代码来源:CardsUnderTest.cs

示例11: TestCardComparison_BothAreSame

        public void TestCardComparison_BothAreSame()
        {
            List<Card> deck = DeckOfCards.GetPokerDeck();

            Card highCard = new Card { rank = Rank.Ten, suit = Suit.Clubs };
            Card sameCard = new Card { rank = Rank.Ten, suit = Suit.Clubs };

            string actual = string.Format("{0} is {1} {2}", highCard.ToString(),
               highCard.CompareTo(sameCard) == -1 ? "lower than" : highCard.CompareTo(sameCard) == 1 ? "higher than"
               : "the same as", sameCard.ToString());

            string expected = "Ten of Clubs is the same as Ten of Clubs";
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
开发者ID:iranye,项目名称:WorkingProjects,代码行数:14,代码来源:CardsUnderTest.cs

示例12: TestCardCompareTwoWithJack

        public void TestCardCompareTwoWithJack()
        {
            Card jack = new Card(CardFace.Jack, CardSuit.Hearts);
            Card two = new Card(CardFace.Two, CardSuit.Hearts);

            int expected = -9;
            int actual = two.CompareTo(jack);
            Assert.AreEqual(expected, actual);
        }
开发者ID:nkolarov,项目名称:telerik-academy,代码行数:9,代码来源:CardTests.cs


注:本文中的Card.CompareTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。