Beispiel #1
0
        public void CantPlayDevelopmentMultipleDevelopmentCardsIn1Turn()
        {
            var player = new Mock<IPlayer>();
            var state1 = new Mock<ITurnState>();
            var provider = new Mock<IStateProvider>();
            provider.Setup(p => p.HasNext()).Returns(true);
            provider.Setup(p => p.GetNext()).Returns(state1.Object);
            state1.Setup(s => s.Commands).Returns(new GameCommand[] { GameCommand.PlayDevelopmentCard });

            var card = new Mock<IDevelopmentCard>();
            card.Setup(c => c.Type).Returns(DevelopmentCardType.Monopoly);
            var turn = new Turn(player.Object, provider.Object);
            turn.NextFlowState();

            turn.PlayDevelopmentCard(card.Object);
            Assert.Throws<InvalidOperationException>(() => turn.PlayDevelopmentCard(card.Object));
        }
Beispiel #2
0
        public void ExpectPlayDevelopmentCardToSetDevelomentCardState(DevelopmentCardType type)
        {
            var player = new Mock<IPlayer>();
            var state1 = new Mock<ITurnState>();
            var provider = new Mock<IStateProvider>();
            provider.Setup(p => p.HasNext()).Returns(true);
            provider.Setup(p => p.GetNext()).Returns(state1.Object);
            state1.Setup(s => s.Commands).Returns(new GameCommand[] { GameCommand.PlayDevelopmentCard });

            var card = new Mock<IDevelopmentCard>();
            card.Setup(c => c.Type).Returns(type);
            var turn = new Turn(player.Object, provider.Object);
            turn.NextFlowState();

            bool changed = false;
            turn.StateChanged += (sender, args) => { changed = true; };

            turn.PlayDevelopmentCard(card.Object);

            provider.Verify(p => p.Get(type));
            Assert.True(changed);
        }
Beispiel #3
0
        public void ExpectPlayDevelopmentCardToFailIfNull()
        {
            var player = new Mock<IPlayer>();
            var state1 = new Mock<ITurnState>();
            var provider = new Mock<IStateProvider>();
            provider.Setup(p => p.HasNext()).Returns(true);
            provider.Setup(p => p.GetNext()).Returns(state1.Object);
            state1.Setup(s => s.Commands).Returns(new GameCommand[] { GameCommand.PlayDevelopmentCard });

            var turn = new Turn(player.Object, provider.Object);
            turn.NextFlowState();

            Assert.Throws<ArgumentNullException>(() => turn.PlayDevelopmentCard(null));
        }
Beispiel #4
0
        public void ExpectPlayDevelopmentCardToFailIfCardIsVictoryPoint()
        {
            var player = new Mock<IPlayer>();
            var state1 = new Mock<ITurnState>();
            var provider = new Mock<IStateProvider>();
            provider.Setup(p => p.HasNext()).Returns(true);
            provider.Setup(p => p.GetNext()).Returns(state1.Object);
            state1.Setup(s => s.Commands).Returns(new GameCommand[] { GameCommand.PlayDevelopmentCard });

            var card = new Mock<IDevelopmentCard>();
            card.Setup(c => c.Type).Returns(DevelopmentCardType.VictoryPoint);
            var turn = new Turn(player.Object, provider.Object);
            turn.NextFlowState();

            Assert.Throws<ArgumentException>(() => turn.PlayDevelopmentCard(card.Object));
        }
Beispiel #5
0
        public void ExpectPlayDevelopmentCardToFailIfCurrentStateCantExecute()
        {
            var player = new Mock<IPlayer>();
            var state1 = new Mock<ITurnState>();
            var provider = new Mock<IStateProvider>();
            provider.Setup(p => p.HasNext()).Returns(true);
            provider.Setup(p => p.GetNext()).Returns(state1.Object);
            state1.Setup(s => s.Commands).Returns(new GameCommand[] { GameCommand.BuildRoad });

            var card = new Mock<IDevelopmentCard>();
            card.Setup(c => c.Type).Returns(DevelopmentCardType.RoadBuilding);

            var turn = new Turn(player.Object, provider.Object);
            turn.NextFlowState();

            Assert.Throws<InvalidOperationException>(() => turn.PlayDevelopmentCard(card.Object));
        }