Exemplo n.º 1
0
        public void TestSetPosition()
        {
            Monopoly game = Monopoly.GetInstance();

            game[0].GoToCase(39);
            Assert.AreEqual(game[0].CurrentPosition.value, 39);
        }
Exemplo n.º 2
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.º 3
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.º 4
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.º 5
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.º 6
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.º 7
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);
        }
Exemplo n.º 8
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
        }