public void Setup_GameWith2Players_ShouldWork()
        {
            game = new Monopoly(null, null, null);
            game.AddPlayer(horse);
            game.AddPlayer(car);

            Assert.Contains(horse, game.Players);
            Assert.Contains(car, game.Players);
        }
        public void Rounds_GameWith2Players_ShouldPlayFor200Rounds()
        {
            game = new Monopoly(null, null, null);
            game.AddPlayer(horse);
            game.AddPlayer(car);
            game.Start();

            Assert.Equal(200, game.Rounds);
            Assert.Equal(200, horse.Rounds);
            Assert.Equal(200, car.Rounds);
        }
Exemplo n.º 3
0
        public void TestAddingPlayers()
        {
            Monopoly game = Monopoly.GetInstance();

            //Adding players
            game.AddPlayer("Jean");
            game.AddPlayer("Paul");
            game.AddPlayer("Jacques");

            Assert.AreEqual(game[0], new Player("Jean", null));
        }
Exemplo n.º 4
0
        public void TestGoToJailwDouble()
        {
            Monopoly game = Monopoly.GetInstance();

            game.Restart(); //In case an instance already exists
            game.AddPlayer("Jean");
            game.AddPlayer("Paul");
            game.AddPlayer("Jacques");
            game[0].Play(4, 4); //Simulates making two 4s three times in a row
            Assert.AreEqual(game[0].InPrison, true);
        }
Exemplo n.º 5
0
        public void TestCircularity()
        {
            Monopoly game = Monopoly.GetInstance();

            game.Restart(); //In case an instance already exists
            game.AddPlayer("Jean");
            game.AddPlayer("Paul");
            game.AddPlayer("Jacques");

            game[0].GoToCase(39);

            Assert.AreEqual(game[0].CurrentPosition.next.value, 0);
        }
Exemplo n.º 6
0
        public void OutOfJail1wDouble()
        {
            Monopoly game = Monopoly.GetInstance();

            game.Restart(); //In case an instance already exists
            game.AddPlayer("Jean");
            game.AddPlayer("Paul");
            game.AddPlayer("Jacques");

            game[0].Play(4, 4);
            game[0].Play(4, 4);

            Assert.AreEqual(game[0].InPrison, false);
            Assert.AreEqual(game[0].CurrentPosition.value, 18);
        }
Exemplo n.º 7
0
        public void TestGoToJailOn30()
        {
            Monopoly game = Monopoly.GetInstance();

            game.Restart(); //Because with the sigleton pattern it keeps the ulterior state
            //Adding players
            game.AddPlayer("Jean");
            game.AddPlayer("Paul");
            game.AddPlayer("Jacques");

            game[0].Play(4, 6);
            game[0].Play(4, 6);
            game[0].Play(4, 6);
            Assert.AreEqual(game[0].InPrison, true);
        }
Exemplo n.º 8
0
        public void OutOfJail1w3Rounds()
        {
            Monopoly game = Monopoly.GetInstance();

            game.Restart(); //In case an instance already exists
            game.AddPlayer("Jean");
            game.AddPlayer("Paul");
            game.AddPlayer("Jacques");

            game[0].Play(4, 4); //Go to Jail (it simulate 3 doubles in a row)

            game[0].Play(2, 6);
            game[0].Play(3, 6);
            game[0].Play(4, 6);


            Assert.AreEqual(game[0].InPrison, false);
            Assert.AreEqual(game[0].CurrentPosition.value, 20);
        }
        public void Setup_GameWithWrongNumberOfPlayers_ShouldThrowException(int numPlayers)
        {
            game = new Monopoly(null, null, null);

            for (int i = 0; i < numPlayers; i++)
            {
                game.AddPlayer(new Player(i.ToString()));
            }

            Assert.Throws <InvalidOperationException>(() => game.Start());
        }
Exemplo n.º 10
0
        public void Birthday_WithTwoOtherPlayers_ShouldCollect20Dollars()
        {
            Monopoly game     = new Monopoly(null, null, null);
            Board    board    = new CardBoard();
            Birthday birthday = new Birthday();
            Player   horse    = new Player("Horse");
            Player   car      = new Player("Car");
            Player   shoe     = new Player("Shoe");

            game.AddPlayer(horse);
            game.AddPlayer(car);
            game.AddPlayer(shoe);
            board.AddPlayerToBoard(car, 0);
            board.AddPlayerToBoard(horse, 0);
            board.AddPlayerToBoard(shoe, 0);

            birthday.Execute(horse);

            Assert.Equal(20, horse.Bank);
            Assert.Equal(-10, car.Bank);
            Assert.Equal(-10, shoe.Bank);
        }
Exemplo n.º 11
0
        public void Setup_GameWith2Players_ShouldRandomizeOrder()
        {
            bool horseFirst = false;
            bool carFirst   = false;

            for (int i = 0; i < 100; i++)
            {
                game = new Monopoly(null, null, null);
                game.AddPlayer(horse);
                game.AddPlayer(car);
                game.Start();
                if (game.Players[0].Name == "Horse")
                {
                    horseFirst = true;
                }
                if (game.Players[0].Name == "Car")
                {
                    carFirst = true;
                }
            }

            Assert.True(horseFirst && carFirst);
        }
Exemplo n.º 12
0
        public static void Problem3()
        {
            Console.WriteLine("Creation of the Game:");
            Monopoly game = Monopoly.GetInstance();

            #region Add players
            //Adding players
            game.AddPlayer("Jean");
            game.AddPlayer("Paul");
            game.AddPlayer("Jacques");
            game.AddPlayer("Christine");
            game.AddPlayer("UselessPlayer");
            Console.WriteLine(game);
            #endregion

            #region Try deleting a player
            game.DeletePlayer("UselessPlayer");
            Console.WriteLine("UselessPlayer Deleted:");
            Console.WriteLine(game);
            #endregion

            #region Simulating some round
            Console.WriteLine("\nHow many rounds do you want to simulate ? ");
            string n;
            int    value;
            do
            {
                n = Console.ReadLine();
            } while (!int.TryParse(n, out value));


            for (int i = 0; i < value; i++)
            {
                game.PlayRound();
            }
            #endregion

            #region Others different check
            //Try adding a player during the game
            game.AddPlayer("Cassandre");
            //! You can't add players when the game has already started

            //Check if the iterator pattern works properly
            Console.WriteLine(game);

            //Check if the singleton pattern works properly
            Console.WriteLine("\nLet's check that the singleton pattern works properly");
            Monopoly game2 = Monopoly.GetInstance();
            Console.WriteLine(game2);
            // !! This is exactly the same game, the iterator pattern is working properly.

            //Let's see the historic of moves of Jacques:
            Console.WriteLine("\nLet's see the historic of Jacques");
            game.ShowHistoric("Jacques");

            //Let's see if we can delete the last move of Jacques
            Console.WriteLine("\nLet's try to delete the last move of Jacques");
            game.Restore("Jacques");
            game.ShowHistoric("Jacques");
            #endregion
        }