public void correct_banker_should_be_loaded_on_load_game()
        {
            var gameOfMonopoly = new Monopoly();

            // Make him pay a bit of money so we know if it's the same
            // banker being loaded
            Banker.Access().Pay(1000);

            var bankerBeforeSavedBalance = Banker.Access().GetBalance();

            // Need to players on the board for saving and loading correctly
            Board.Access().AddPlayer(new Player());
            Board.Access().AddPlayer(new Player());

            gameOfMonopoly.SaveGame();

            // Set the banker's balance to something random so we know
            // it's then changed when we load the game that has the
            // other banker's balance from the previous save
            Banker.Access().SetBalance(500);

            gameOfMonopoly.LoadGame();

            var bankerAfterLoadedBalance = Banker.Access().GetBalance();

            // The balance should be what it was when we saved it even though we
            // changed it, this is because the banker we're loading is the one
            // before we changed the balance
            Assert.AreEqual(bankerBeforeSavedBalance, bankerAfterLoadedBalance);
        }
        public void correct_banker_should_be_loaded_on_load_game()
        {
            var gameOfMonopoly = new Monopoly();

            // Make him pay a bit of money so we know if it's the same
            // banker being loaded
            Banker.Access().Pay(1000);

            var bankerBeforeSavedBalance = Banker.Access().GetBalance();

            // Need to players on the board for saving and loading correctly
            Board.Access().AddPlayer(new Player());
            Board.Access().AddPlayer(new Player());

            gameOfMonopoly.SaveGame();

            // Set the banker's balance to something random so we know
            // it's then changed when we load the game that has the
            // other banker's balance from the previous save
            Banker.Access().SetBalance(500);

            gameOfMonopoly.LoadGame();

            var bankerAfterLoadedBalance = Banker.Access().GetBalance();

            // The balance should be what it was when we saved it even though we 
            // changed it, this is because the banker we're loading is the one
            // before we changed the balance
            Assert.AreEqual(bankerBeforeSavedBalance, bankerAfterLoadedBalance);
        }
Beispiel #3
0
        public void loading_board_from_saved_board()
        {
            Board.Access().ResetBoard();

            CollectionAssert.IsEmpty(Board.Access().GetProperties());

            _gameOfMonopoly.SetUpProperties();
            Board.Access().AddPlayer(new Player());
            Board.Access().AddPlayer(new Player());
            _gameOfMonopoly.SaveGame();

            _gameOfMonopoly.LoadGame();

            Assert.AreEqual(40, Board.Access().GetProperties().Count);

            var bankerOwnedProperty = (Property)Board.Access().GetProperties().ToArray().First();

            // Owner should be the banker for this property
            Assert.AreEqual(Banker.Access(), bankerOwnedProperty.GetOwner());

            // Need to reset the the save file to a blank board
            // for when actually playing the game
            Board.Access().ResetBoard();
            _gameOfMonopoly.SaveGame();
        }