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 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(); }
public void BeforeAll() { var residentialFactory = new ResidentialFactory(); _tradeableProperty = residentialFactory.create("Test Residential", 200, 50, 50, "Red"); _player = new Player("Josh", 500); _banker = Banker.Access(); }
public TradeableProperty TradeProperty(Player purchaser) { var transportFactory = new TransportFactory(); TradeableProperty tradeableProperty = transportFactory.create("Railway Station"); // The trader should be the banker as they own the property Trader trader = Banker.Access(); trader.TradeProperty(ref tradeableProperty, ref purchaser, tradeableProperty.GetPrice(), Decimal.Zero); return(tradeableProperty); }
public void rent_is_not_doubled_for_undeveloped_prop_single_owner_colour_banker() { Board.Access().ResetBoard(); var banker = Banker.Access(); _residentialProperty = NewResidential(); _residentialProperty.SetOwner(ref banker); Board.Access().AddProperty(_residentialProperty); const decimal orginalRent = 14; var actualRent = _residentialProperty.GetRent(); Assert.AreEqual(orginalRent, actualRent); }
public void a_bankrupt_players_properties_should_become_the_bankers() { // bankrupt that mofo _emptyPlayer.SetBalance(0); _emptyPlayer.PlayerBankrupt += _testHelper.TestPlayerBankruptHandler; // create a property, add it to the board, and set the owner to the player under test var propertyOfBankruptPlayer = new Property("Test Property"); Board.Access().AddProperty(propertyOfBankruptPlayer); propertyOfBankruptPlayer.SetOwner(ref _emptyPlayer); _emptyPlayer.CheckBankrupt(); // owner of the property should now be the banker Assert.IsTrue(propertyOfBankruptPlayer.GetOwner().Equals(Banker.Access())); }
public void unmortgaging_property_results_in_correct_balance_alterations() { _residentialProperty = NewResidential(); var testPlayer = GetMeANewPlayer(); var paybackValue = _residentialProperty.GetMortgageValue() + (_residentialProperty.GetMortgageValue() * 10 / 100);// mortgage plus 10% _residentialProperty.SetOwner(ref testPlayer); _residentialProperty.MortgageProperty(); var ownerBalaceBeforeUnmortgage = testPlayer.GetBalance(); var bankerBalanceBeforeUnmortgage = Banker.Access().GetBalance(); _residentialProperty.UnmortgageProperty(); // The property's owner should have paid the mortgage payback value Assert.AreEqual(ownerBalaceBeforeUnmortgage - paybackValue, testPlayer.GetBalance()); // The banker should have received the mortgage payback value Assert.AreEqual(bankerBalanceBeforeUnmortgage + paybackValue, Banker.Access().GetBalance()); }
public void mortgaging_property_results_in_correct_balance_alterations() { _residentialProperty = NewResidential(); var testPlayer = GetMeANewPlayer(); var mortgageValue = _residentialProperty.GetMortgageValue(); var ownerBalanceBefore = testPlayer.GetBalance(); var bankerBalanceBefore = Banker.Access().GetBalance(); _residentialProperty.SetOwner(ref testPlayer); _residentialProperty.MortgageProperty(); // Property should now be mortgaged Assert.IsTrue(_residentialProperty.IsMortgaged); // The property's owner should have received the mortgage money Assert.AreEqual(ownerBalanceBefore + mortgageValue, testPlayer.GetBalance()); // The banker should have paid the mortgage money Assert.AreEqual(bankerBalanceBefore - mortgageValue, Banker.Access().GetBalance()); }
public void test_singleton() { //Access banker twice and tests that it is the same object Assert.AreSame(Banker.Access(), Banker.Access()); }