Ejemplo n.º 1
0
        public void ExpectStateTransitionIfNoPlayers()
        {
            var turn = new Mock<IGameTurn>();
            var players = new List<IPlayer>();
            var state = new RobberDiscardState(turn.Object, players);


            turn.Verify(t => t.SetState<MoveRobberState>(), Times.Once);
        }
Ejemplo n.º 2
0
        public void ExpectStateTransitionAfterPlayerDiscardedTheirResources()
        {
            var turn = new Mock<IGameTurn>();
            var player = new Mock<IPlayer>();
            player.Setup(p => p.Inventory).Returns(Enumerable.Range(0, 8).Select(i => new Mock<IRawMaterial>().Object));
            var players = new List<IPlayer>() { player.Object };

            var state = new RobberDiscardState(turn.Object, players);
                        
            player.Setup(p => p.Inventory).Returns(Enumerable.Range(0, 4).Select(i => new Mock<IRawMaterial>().Object));
            state.AfterExecute(GameCommand.DiscardResources);
            turn.Verify(t => t.SetState<MoveRobberState>(), Times.Once);
        }
Ejemplo n.º 3
0
        public void ExpectStateTransitionIfNoPlayerToMuchResources()
        {
            var turn = new Mock<IGameTurn>();
            var player1 = new Mock<IPlayer>();
            var player2 = new Mock<IPlayer>();

            player1.Setup(p => p.Inventory).Returns(new IRawMaterial[] { });
            player2.Setup(p => p.Inventory).Returns(Enumerable.Range(0, 7).Select(i => new Mock<IRawMaterial>().Object));
            var players = new List<IPlayer>() { player1.Object, player2.Object };
            var state = new RobberDiscardState(turn.Object, players);


            turn.Verify(t => t.SetState<MoveRobberState>(), Times.Once);
        }
Ejemplo n.º 4
0
        public void ExpectNoStateChangeIfPlayerRemovedNotEnoughResources()
        {
            var turn = new Mock<IGameTurn>();
            var player = new Mock<IPlayer>();
            player.Setup(p => p.Inventory).Returns(Enumerable.Range(0, 8).Select(i => new Mock<IRawMaterial>().Object));
            var players = new List<IPlayer>() { player.Object };


            var state = new RobberDiscardState(turn.Object, players);

            player.Setup(p => p.Inventory).Returns(Enumerable.Range(0, 5).Select(i => new Mock<IRawMaterial>().Object));
            state.AfterExecute(GameCommand.DiscardResources);

            turn.Verify(t => t.SetState<MoveRobberState>(), Times.Never);

        }
Ejemplo n.º 5
0
        public void ExpectedRemoveResourcesIsHalfROundedDown(int initial, int expected)
        {
            var turn = new Mock<IGameTurn>();
            var player = new Mock<IPlayer>();
            player.Setup(p => p.Inventory).Returns(Enumerable.Range(0, initial).Select(i => new Mock<IRawMaterial>().Object));
            var players = new List<IPlayer>() { player.Object };


            var state = new RobberDiscardState(turn.Object, players);
            //expect 4 removed

            player.Setup(p => p.Inventory).Returns(Enumerable.Range(0, expected).Select(i => new Mock<IRawMaterial>().Object));
            state.AfterExecute(GameCommand.DiscardResources);

            turn.Verify(t => t.SetState<MoveRobberState>(), Times.Once);

        }