Beispiel #1
0
        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());
        }