示例#1
0
        public void TakeActionWithDrawFourCardTest()
        {
            var game = GameFactory.InProgress();

            game.CurrentColor = Color.Red;
            game.Hands[0]     = HandFactory.DrawFour(game.Hands[0].Player);
            var action      = new Action(game);
            var currentTurn = game.Turn.Value;
            var currentHand = action.GetHand(currentTurn);

            var input        = $"{currentHand.Cards.First(c => c.Value == "D4").Display} y";
            var discardCount = game.Discard.Count;
            var deckCount    = game.Deck.Cards.Count;
            var card         = Card.Create(input);
            var inHandCount  = currentHand.Cards.Count(c => c.Display == card.Display);

            action.TakeAction(card);

            // assuming a 2 player game, the turn index shuold appear the same
            Assert.True(game.Turn.Value == currentTurn);
            Assert.True(game.Discard.Peek().Display == card.Display);
            Assert.True(game.Discard.Count == discardCount + 1);
            Assert.True(game.CurrentColor == card.NewColor);
            Assert.True(game.CurrentValue == card.Value);
            Assert.True(game.Deck.Cards.Count == deckCount - 4);

            var newHand        = action.GetHand(currentTurn);
            var newInHandCount = newHand.Cards.Count(c => c.Display == input);

            Assert.True(newInHandCount < inHandCount);
        }
示例#2
0
        public void TakeActionWithDrawFourCardInvalidPlayTest()
        {
            var game = GameFactory.InProgress();

            game.CurrentColor = Color.Red;
            game.Hands[0]     = HandFactory.DrawFour(game.Hands[0].Player);
            game.Hands[0].Cards.Add(new Card {
                Color = Color.Red, Display = "r1", Value = "1"
            });
            var action      = new Action(game);
            var currentTurn = game.Turn.Value;
            var currentHand = action.GetHand(currentTurn);

            var input          = $"{currentHand.Cards.First(c => c.Value == "D4").Display} y";
            var discardCount   = game.Discard.Count;
            var discardTopCard = game.Discard.Peek().Display;

            var card        = Card.Create(input);
            var inHandCount = currentHand.Cards.Count(c => c.Display == card.Display);

            action.TakeAction(card);

            Assert.True(game.Turn.Value == currentTurn);
            Assert.True(game.Discard.Peek().Display == discardTopCard);
            Assert.True(game.Discard.Count == discardCount);

            var newHand        = action.GetHand(currentTurn);
            var newInHandCount = newHand.Cards.Count(c => c.Display == card.Display);

            Assert.True(newInHandCount == inHandCount);
        }