Example #1
0
        public void BuyDevelopmentCardFailsIfPlayerNotCurrentTurnPlayer()
        {
            var players = CreateFakePlayers(3);
            var provider = new Mock<ITurnProvider>();
            var turn = new Mock<IGameTurn>();
            var player = new Mock<IPlayer>();

            turn.Setup(t => t.Player).Returns(new Mock<IPlayer>().Object);
            provider.Setup(p => p.GetNext()).Returns(turn.Object);

            var card = new Mock<IDevelopmentCard>();
            var bank = new Mock<IBank>();

            var game = new Game(players, provider.Object, bank.Object);
            game.Start();

            Assert.Throws<InvalidOperationException>(() => game.BuyDevelopmentCard(player.Object));
        }
Example #2
0
        public void BuyDevelopmentCardTest()
        {
            var players = CreateFakePlayers(3);
            var provider = new Mock<ITurnProvider>();
            var turn = new Mock<IGameTurn>();
            var player = new Mock<IPlayer>();

            turn.Setup(t => t.Player).Returns(player.Object);
            provider.Setup(p => p.GetNext()).Returns(turn.Object);

            var card = new Mock<IDevelopmentCard>();
            var bank = new Mock<IBank>();

            var game = new Game(players, provider.Object, bank.Object);
            game.Start();

            game.BuyDevelopmentCard(player.Object);

            bank.Verify(b => b.BuyDevelopmentCard(player.Object, turn.Object));
        }
Example #3
0
        public void BuyDevelopmentCardFailsIfPlayerNull()
        {
            var players = CreateFakePlayers(3);
            var provider = new Mock<ITurnProvider>();
            var turn = new Mock<IGameTurn>();
            provider.Setup(p => p.GetNext()).Returns(turn.Object);

            var card = new Mock<IDevelopmentCard>();
            var bank = new Mock<IBank>();

            var game = new Game(players, provider.Object, bank.Object);
            game.Start();

            Assert.Throws<ArgumentNullException>(() => game.BuyDevelopmentCard(null));
        }