public void TestWhenSpecifyingBigBangMode_ThenFirstMoveIsDynamite()
        {
            var target = new MyBot_Accessor();
            target.Mode = MoveMode.BigBang;
            var testPlayer = new Player("Test", target);

            IPlayer opponent = new Player("Opponent", new MyBot());
            Move expected = Moves.Dynamite;
            Move actual = target.MakeMove(testPlayer, opponent, GameRules.Default);
            Assert.AreEqual(expected, actual, "Big Bang always starts with Dynamite.");
        }
        public void TestWhenCausingAnExceptionInMakeMyMove_ThenAValidMoveIsStillReturned()
        {
            var target = new MyBot_Accessor();
            target.History = null;
            var testPlayer = new Player("Test", target);

            IPlayer opponent = new Player("Opponent", new MyBot());
            Move notExpected = Moves.WaterBalloon;
            Move actual = target.MakeMove(testPlayer, opponent, GameRules.Default);
            Assert.AreNotEqual(notExpected, actual, "Exception move should not return WaterBalloon.");
        }
Exemple #3
0
        private short PlaySomeOpponentManyTimes(MoveMode mode, short gameCount)
        {
            short wins = 0;
            var results = new List<GameResults>();

            Parallel.For(0, gameCount, i =>
                {
                    Player you = new Player("Test", new MyBot());
                    var accessor = new MyBot_Accessor();
                    accessor.Mode = mode;
                    Player opponent = new Player("Opponent", accessor);

                    Game game = new Game(GameRules.Default);
                    GameResults result = game.Play(you, opponent);

                    if (result.Winner.TeamName.Equals("Test")) wins++;
                    results.Add(result);
                });

            VerifyResults(results, String.Format("against {0}", mode));
            return wins;
        }
        public void TestWhenSpecifyingCycleMode_ThenFirstMoveIsRock()
        {
            var target = new MyBot_Accessor();
            target.Mode = MoveMode.Cycle;
            var testPlayer = new Player("Test", target);

            IPlayer opponent = new Player("Opponent", new MyBot());
            Move expected = Moves.Rock;
            Move actual = target.MakeMove(testPlayer, opponent, GameRules.Default);
            Assert.AreEqual(expected, actual, "Cycle always starts with Rock.");
        }