Beispiel #1
0
        public void PickProcessor_ContinueFromHumanPickTurn_WrongTurn()
        {
            var humanMock = new Mock <IHumanPlayer>();

            humanMock.Setup(m => m.Cards).Returns(new List <SheepCard>());
            var computerPlayer    = new Mock <IComputerPlayer>().Object;
            var pickProcessorMock = new Mock <IPickProcessor>();
            var handMock          = new Mock <IHand>();

            handMock.Setup(m => m.Blinds).Returns(new List <SheepCard>());
            handMock.Setup(m => m.PlayersWithoutPickTurn).Returns(new List <IPlayer>()
            {
                computerPlayer, humanMock.Object
            });

            var pickProcessor  = new PickProcessor();
            var threwException = false;

            try
            {
                var hand = pickProcessor.ContinueFromHumanPickTurn(humanMock.Object, true, handMock.Object, pickProcessorMock.Object);
            }
            catch (NotPlayersTurnException)
            {
                threwException = true;
            }
            Assert.IsTrue(threwException);
        }
Beispiel #2
0
        public void PickProcessor_ContinueFromHumanPickTurn_HumanPicks()
        {
            var humanCards = new List <SheepCard>();
            var humanMock  = new Mock <IHumanPlayer>();

            humanMock.Setup(m => m.Cards).Returns(humanCards);
            humanMock.Setup(f => f.AddCard(It.IsAny <SheepCard>())).Callback((SheepCard c) => humanCards.Add(c));
            humanMock.Setup(f => f.RemoveCard(It.IsAny <SheepCard>())).Callback((SheepCard c) => humanCards.Remove(c));
            var pickProcessorMock = new Mock <IPickProcessor>();

            pickProcessorMock
            .Setup(m => m.PlayNonHumanPickTurns(It.IsAny <IHand>()))
            .Callback(() => Assert.Fail("Should not have let non humans pick."));
            var blinds = new List <SheepCard>()
            {
                0, (SheepCard)1
            };
            IPlayer actualPicker = null;
            var     handMock     = new Mock <IHand>();

            handMock.Setup(m => m.SetPicker(It.IsAny <IPlayer>(), It.IsAny <List <SheepCard> >())).Callback <IPlayer, List <SheepCard> >((p, c) => actualPicker = p);
            handMock.Setup(m => m.Blinds).Returns(blinds);
            handMock.Setup(m => m.PlayersWithoutPickTurn).Returns(new List <IPlayer>()
            {
                humanMock.Object, new Mock <IComputerPlayer>().Object
            });

            var pickProcessor = new PickProcessor();
            var hand          = pickProcessor.ContinueFromHumanPickTurn(humanMock.Object, true, handMock.Object, pickProcessorMock.Object);

            Assert.AreSame(humanMock.Object, actualPicker);
            Assert.IsTrue(humanCards.Contains(blinds[0]));
            Assert.IsTrue(humanCards.Contains(blinds[1]));
        }
Beispiel #3
0
        public void PickProcessor_ContinueFromHumanPickTurn_HumanDeclinesButCompterPicks()
        {
            var humanMock       = (new Participant()
            {
                Type = "H"
            }).Player as IHumanPlayer;
            var expectedPicker  = (new Participant()
            {
                Type = "S"
            }).Player as IComputerPlayer;
            var refusingPlayers = new List <IPlayer>();
            var handMock        = new Mock <IHand>();

            handMock.Setup(m => m.PlayersRefusingPick).Returns(refusingPlayers);
            handMock.Setup(m => m.PlayerWontPick(It.IsAny <IPlayer>())).Callback((IPlayer p) => refusingPlayers.Add(p));
            handMock.Setup(m => m.PlayersWithoutPickTurn).Returns(new List <IPlayer>()
            {
                humanMock, expectedPicker
            });
            var pickProcessorMock  = new Mock <IPickProcessor>();
            var nonHumansGotToPlay = false;

            pickProcessorMock
            .Setup(m => m.PlayNonHumanPickTurns(It.IsAny <IHand>()))
            .Callback(() => {
                handMock.Setup(m => m.Picker).Returns(expectedPicker);
                nonHumansGotToPlay = true;
            })
            .Returns(expectedPicker);

            var pickProcessor = new PickProcessor();

            pickProcessor.ContinueFromHumanPickTurn(humanMock, false, handMock.Object, pickProcessorMock.Object);

            Assert.IsTrue(refusingPlayers.Contains(humanMock));
            Assert.IsTrue(nonHumansGotToPlay);
        }