public void SellDevelopableLand_Developed_Unmortgaged() { int[] rentTable = new int[6] { 4, 20, 60, 180, 320, 500 }; DevelopableLand gangstersParadise = new DevelopableLand("Gangsters Paradise", 60, Colour.Brown, rentTable); // develop property with 1 house gangstersParadise.Develop(); Assert.AreEqual(1, gangstersParadise.GetHouses()); // check if property can be sold Assert.IsFalse(gangstersParadise.CanSellProperty()); // cannot sell, must undevelop property first gangstersParadise.Undevelop(); Assert.AreEqual(0, gangstersParadise.GetHouses()); // unmortgaged property sells for original price value (£60) Assert.IsTrue(gangstersParadise.CanSellProperty()); int sellingPrice = gangstersParadise.SellPropertyToBank(); Assert.AreEqual(60, sellingPrice); // property is unowned after selling Assert.IsNull(gangstersParadise.GetOwner()); }
public void DevelopableLand_CalculateTotalValue() { int[] rentTable = new int[6] { 30, 60, 100, 150, 200, 320 }; int price = 200; Colour group = Colour.Blue; DevelopableLand reyLane = new DevelopableLand("Rey Lane", price, group, rentTable); // total value = original price (unmortgaged, undeveloped) Assert.AreEqual(200, reyLane.CalculateTotalValue()); // mortgage undeveloped property reyLane.Mortgage(); Assert.IsTrue(reyLane.IsMortgaged()); // total value = original price / 2 Assert.AreEqual(100, reyLane.CalculateTotalValue()); // unmortgaged property reyLane.Unmortgage(); Assert.IsFalse(reyLane.IsMortgaged()); // develop property with 3 houses for (int i = 0; i < 3; i++) { reyLane.Develop(); } Assert.AreEqual(3, reyLane.GetHouses()); // get correct house price int housePrice = reyLane.GetDevelopCost(); Assert.AreEqual(50, housePrice); // total value = original price + (3 * houseprice) int correctTotal = 200 + (3 * 50); Assert.AreEqual(correctTotal, reyLane.CalculateTotalValue()); // mortgage property reyLane.Mortgage(); Assert.IsTrue(reyLane.IsMortgaged()); //total value = (original price / 2) + (3 * houseprice) int correctTotal2 = (200 / 2) + (3 * housePrice); Assert.AreEqual(correctTotal2, reyLane.CalculateTotalValue()); }
public void DevelopableLand_SellProperty() { int[] rentTable = new int[6] { 60, 70, 80, 90, 100, 200 }; DevelopableLand ibisClose = new DevelopableLand("Ibis Close", 400, Colour.DeepBlue, rentTable); // sell property to bank Assert.AreEqual(400, ibisClose.SellPropertyToBank()); // develop the property and attempt to sell it ibisClose.Develop(); try { ibisClose.SellPropertyToBank(); } catch (DevelopableLandException e) { Console.WriteLine(e.Message); Assert.AreEqual("Cannot sell the property while it is developed!", e.Message); } }