예제 #1
0
        public void TestPlayer2PullsOneAceFromPlayer3AndPlayer3Pulls2AcesFromPlayer2()
        {
            Player2 p2 = new Player2
            {
                Hand = new List <Card>
                {
                    new Card(Suits.Hjärter, Values.Ess),
                    new Card(Suits.Hjärter, Values.Kung),
                    new Card(Suits.Hjärter, Values.Dam),
                    new Card(Suits.Hjärter, Values.Knekt),
                    new Card(Suits.Hjärter, Values.Tio)
                }
            };

            Player3 p3 = new Player3
            {
                Hand = new List <Card>
                {
                    new Card(Suits.Spader, Values.Ess),
                    new Card(Suits.Spader, Values.Kung),
                    new Card(Suits.Spader, Values.Dam),
                    new Card(Suits.Spader, Values.Knekt),
                    new Card(Suits.Spader, Values.Tio)
                }
            };

            p2.Opponents = new List <BasePlayer> {
                p3
            };
            p3.Opponents = new List <BasePlayer> {
                p2
            };

            p2.CardExchangeAnnouncementCallback += p3.OtherPlayersPlayed;
            p3.CardExchangeAnnouncementCallback += p2.OtherPlayersPlayed;

            IEnumerable <Card> p2Recieved = p3.GetCards(Values.Ess);

            p2.CardExchangeAnnouncementCallback?.Invoke(p2, p3, Values.Ess, p2Recieved);
            p3.CardExchangeAnnouncementCallback?.Invoke(p2, p3, Values.Ess, p2Recieved);

            int expectedHandCountp2 = 6;
            int expectedHandCountp3 = 4;
            int expectedKnownp2     = 1;
            int expectedKnownp3     = 0;

            Assert.AreEqual(expectedHandCountp2, p2.Hand.Count);
            Assert.AreEqual(expectedHandCountp3, p3.Hand.Count);
            Assert.AreEqual(expectedKnownp2, p2.SwappedCards["Player2"].Count);
            Assert.AreEqual(expectedKnownp2, p3.SwappedCards["Player2"].Count);
            Assert.AreEqual(expectedKnownp3, p2.SwappedCards["Player3"].Count);
            Assert.AreEqual(expectedKnownp3, p3.SwappedCards["Player3"].Count);

            IEnumerable <Card> p3Recieved = p2.GetCards(Values.Ess);

            p2.CardExchangeAnnouncementCallback?.Invoke(p3, p2, Values.Ess, p3Recieved);
            p3.CardExchangeAnnouncementCallback?.Invoke(p3, p2, Values.Ess, p3Recieved);

            expectedHandCountp2 = 4;
            expectedHandCountp3 = 6;
            expectedKnownp2     = 0;
            expectedKnownp3     = 2;

            Assert.AreEqual(expectedHandCountp2, p2.Hand.Count);
            Assert.AreEqual(expectedHandCountp3, p3.Hand.Count);
            Assert.AreEqual(expectedKnownp2, p2.SwappedCards["Player2"].Count);
            Assert.AreEqual(expectedKnownp2, p3.SwappedCards["Player2"].Count);
            Assert.AreEqual(expectedKnownp3, p2.SwappedCards["Player3"].Count);
            Assert.AreEqual(expectedKnownp3, p3.SwappedCards["Player3"].Count);
        }