Example #1
0
        public void InitaliseDevelopableLandWithCorrectData()
        {
            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);

            // correct name
            Assert.AreEqual("Rey Lane", reyLane.GetPropertyName());
            // correct price
            Assert.AreEqual(200, reyLane.GetPrice());
            // correct group
            Assert.AreEqual(Colour.Blue, reyLane.GetColourGroup());
            // correct rent table
            var actualRentTable = reyLane.GetRentTable();

            for (int i = 0; i < 5; i++)
            {
                Assert.AreEqual(rentTable[i], actualRentTable[i]);
            }
            // initially unowned
            Assert.IsNull(reyLane.GetOwner());
            // initially unmortgaged
            Assert.IsFalse(reyLane.IsMortgaged());
            // initially undeveloped
            Assert.AreEqual(0, reyLane.GetHouses());
            // implements IProperty interface
            Assert.IsTrue(reyLane is IProperty);
        }
Example #2
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());
        }
Example #3
0
        public void SellDevelopableLand_Mortgaged()
        {
            int[] rentTable = new int[6] {
                4, 20, 60, 180, 320, 450
            };
            DevelopableLand gangstersParadise = new DevelopableLand("Gangsters Paradise",
                                                                    60, Colour.Brown, rentTable);

            // mortgage property
            gangstersParadise.Mortgage();
            Assert.IsTrue(gangstersParadise.IsMortgaged());
            // mortgaged property sells for half price (£30)
            Assert.IsTrue(gangstersParadise.CanSellProperty());
            int sellingPrice = gangstersParadise.SellPropertyToBank();

            Assert.AreEqual(30, sellingPrice);
            // property is unowned and unmortgaged after selling
            Assert.IsNull(gangstersParadise.GetOwner());
            Assert.IsFalse(gangstersParadise.IsMortgaged());
        }