コード例 #1
0
ファイル: GameWorkersTest.cs プロジェクト: f00f-nyc/AllIn
        public void WorkersAreHiredFromPoolFirst()
        {
            BoardState       game = DataTest.SampleGame;
            HireWorkerAction hire = new HireWorkerAction()
            {
                PlayerId = 0
            };

            int workersBefore = GameWorkersTest.UnhiredWorkersCount(game);

            Assert.AreEqual(2, workersBefore, "The test is written based on the assumption that there are exactly 2 workers free in the pool.");

            game = Tick.Apply(game, new List <GameAction> {
                hire
            });
            game = Tick.Apply(game, new List <GameAction> {
                hire
            });
            Assert.AreEqual(0, GameWorkersTest.UnhiredWorkersCount(game));

            Worker[] player2WorkersBefore = GameWorkersTest.GetPlayerWorkers(game, 1);
            game = Tick.Apply(game, new List <GameAction> {
                hire
            });
            Worker[] player2WorkersAfter = GameWorkersTest.GetPlayerWorkers(game, 1);

            Assert.AreEqual(player2WorkersBefore.Length - 1, player2WorkersAfter.Length);
        }
コード例 #2
0
ファイル: GameWorkersTest.cs プロジェクト: f00f-nyc/AllIn
        public void CannotHireWorkerJustFied()
        {
            BoardState       game = DataTest.SampleGame;
            HireWorkerAction hire = new HireWorkerAction()
            {
                PlayerId = 1
            };

            game = Tick.Apply(game, new List <GameAction> {
                hire, hire
            });

            Assert.AreEqual(0, GameWorkersTest.UnhiredWorkersCount(game), "This test relies on the fact that there are exactly two unhired workers");
            FireWorkerAction fire = new FireWorkerAction()
            {
                PlayerId = 1
            };

            game = Tick.Apply(game, new List <GameAction> {
                fire
            });

            Assert.That(game.Players[1].RecentWorkers.Count > 0);
            Assert.AreEqual(1, GameWorkersTest.UnhiredWorkersCount(game));
            game = Tick.Apply(game, new List <GameAction> {
                hire
            });
            Assert.AreEqual(1, GameWorkersTest.UnhiredWorkersCount(game));
        }
コード例 #3
0
ファイル: GameWorkersTest.cs プロジェクト: f00f-nyc/AllIn
        public void HiringAFiredWorkerRemovesRecentWorkerIndicator()
        {
            BoardState       game        = DataTest.SampleGame;
            HireWorkerAction player1Hire = new HireWorkerAction()
            {
                PlayerId = 1
            };

            game = Tick.Apply(game, new List <GameAction> {
                player1Hire, player1Hire
            });

            Assert.AreEqual(0, GameWorkersTest.UnhiredWorkersCount(game), "This test relies on the fact that there are exactly two unhired workers");
            FireWorkerAction fire = new FireWorkerAction()
            {
                PlayerId = 1
            };

            game = Tick.Apply(game, new List <GameAction> {
                fire
            });

            HireWorkerAction player0Hire = new HireWorkerAction()
            {
                PlayerId = 0
            };

            game = Tick.Apply(game, new List <GameAction> {
                player0Hire
            });
            Assert.AreEqual(0, game.Players[1].RecentWorkers.Count);
        }
コード例 #4
0
ファイル: GameWorkersTest.cs プロジェクト: f00f-nyc/AllIn
        public void FireWorkerActionWorks()
        {
            BoardState       game = DataTest.SampleGame;
            FireWorkerAction fire = new FireWorkerAction {
                PlayerId = 0
            };

            game = Tick.Apply(game, new List <GameAction> {
                fire
            });
            Assert.AreEqual(0, GameWorkersTest.GetPlayerWorkers(game, 0).Length);
        }
コード例 #5
0
ファイル: GameWorkersTest.cs プロジェクト: f00f-nyc/AllIn
        public void CannotHireIfGameIsNotStarted()
        {
            BoardState game = DataTest.SampleGame;

            game.State = GameState.GameNotStarted;
            HireWorkerAction hire = new HireWorkerAction {
                PlayerId = 0
            };

            int workersBefore = GameWorkersTest.UnhiredWorkersCount(game);

            game = Tick.Apply(game, new List <GameAction> {
                hire
            });
            Assert.AreEqual(workersBefore, GameWorkersTest.UnhiredWorkersCount(game));
        }