public void test_player_landOn() { //Board.access().resetBoard(true); Player newPlayer1 = new Player("player1", 1500); Player newPlayer2 = new Player("player2", 1500); TradeableProperty theTradeProp = new TradeableProperty(); //set prop owner theTradeProp.setOwner(ref newPlayer1); //String the1 = theTradeProp.landOn(ref newPlayer2); string landon1 = theTradeProp.landOn(ref newPlayer2).ToString(); StringAssert.Contains("$100 to player1", landon1); //set prop mortgaged theTradeProp.setMortgaged(true); string landon2 = theTradeProp.landOn(ref newPlayer2).ToString(); StringAssert.Contains("is currently morgaged skipping rent payment", landon2); String the2 = theTradeProp.landOn(ref newPlayer2); //set owner as landon should be just visting theTradeProp.setMortgaged(false); string landon3 = theTradeProp.landOn(ref newPlayer1).ToString(); StringAssert.Contains("player1 landed on", landon3); }
public void test_pay_rent() { //Board.access().resetBoard(true); Player newPlayer1 = new Player("player1", 1500); Player newPlayer2 = new Player("player2", 1500); decimal expected_player1 = newPlayer1.getBalance() + 100; decimal expected_player2 = newPlayer2.getBalance() - 100; TradeableProperty theTradeProp = new TradeableProperty(); theTradeProp.setOwner(ref newPlayer1); theTradeProp.payRent(ref newPlayer2); Assert.AreEqual(expected_player1, newPlayer1.getBalance()); Assert.AreEqual(expected_player2, newPlayer2.getBalance()); }
public void test_bank_owns_purchase() { Player newPlayer1 = new Player("player1", 1500); Player newPlayer2 = new Player("player2", 1500); TradeableProperty theTradeProp = new TradeableProperty(); theTradeProp.setOwner(ref newPlayer1); //this will throw error as prop should not be availble try { theTradeProp.purchase(ref newPlayer2); } catch (ApplicationException e) { StringAssert.Contains("The property is not available from purchase", e.ToString()); } }
public void tradeProperty(ref TradeableProperty property, ref Player purchaser, decimal amount) { purchaser.pay(amount); this.receive(amount); property.setOwner(ref purchaser); }