コード例 #1
0
ファイル: TLocationModel.cs プロジェクト: arpond/longRoadHome
        public void Setup()
        {
            Residential res;
            Commercial  com;
            Civic       civ;

            lm  = new LocationModel();
            dl1 = new DummyLocation(1);
            dl2 = new DummyLocation(2);
            dl3 = new DummyLocation(3);
            dl4 = new DummyLocation(4);

            dlList = new List <DummyLocation>();
            dlList.Add(dl1);
            dlList.Add(dl2);
            dlList.Add(dl3);
            dlList.Add(dl4);
            //connected = lm.ConnectDummyLocations(dlList);

            res = new Residential(1, 3, 5);
            com = new Commercial(2, 4, 7);
            civ = new Civic(3, 6, 3);

            validLoc.Add(new Tuple <String, String>("Type:Location,ID:1,Visited:True,Sublocations,CurrentSublocation", "Standard location is valid"));
            validLoc.Add(new Tuple <String, String>("Type:Location,ID:2,Visited:True,Sublocations:" + res.ParseToString() + ":" + com.ParseToString() + ",CurrentSublocation:1", "Standard location is valid"));
            validLoc.Add(new Tuple <String, String>("Type:Location,ID:3,Visited:True,Sublocations:" + res.ParseToString() + ":" + civ.ParseToString() + ":" + com.ParseToString() + ",CurrentSublocation:1", "Standard location is valid"));

            validDummy.Add(new Tuple <String, String>("Type:DummyLocation,ID:4", "Standard dummy location is valid"));
            validDummy.Add(new Tuple <String, String>("Type:DummyLocation,ID:5", "Standard dummy location is valid"));
            validDummy.Add(new Tuple <String, String>("Type:DummyLocation,ID:6", "Standard dummy location is valid"));
            validDummy.Add(new Tuple <String, String>("Type:DummyLocation,ID:7", "Standard dummy location is valid"));
            validDummy.Add(new Tuple <String, String>("Type:DummyLocation,ID:8", "Standard dummy location is valid"));
        }
コード例 #2
0
        //Below event of clicking Add Customer button adds customer in the list, calculates total bill amt of customer by their type, count total # of customer and calculate total bill of all customers in list
        private void btnAddCustomer_Click(object sender, EventArgs e)
        {
            Customer c = null;

            if (Validator.IsProvided(txtCustName, "Customer Name") && Validator.IsProvided(txtCustName, "Account Number") && Validator.IsNonNegativeInt(txtAccountNo, "Account Number") && Validator.IsUnique(txtAccountNo, "Account#", lstCustomers))
            {
                if (rdResidential.Checked)
                {
                    c = new Residential(txtCustName.Text, Convert.ToInt32(txtAccountNo.Text), 'R'); //creating Residential customer object
                    c.CustomerCharge = c.calculateBill(int.Parse(txtKwh.Text));                     //Calculatinga a bill amt of  Residential customer
                    res += c.CustomerCharge;                                                        //Adding new bill charge of residential customer to the existing bill amount of Residential customers
                    txtResidentialType.Text = res.ToString("c");
                }
                if (rdCommercial.Checked)
                {
                    c = new Commercial(txtCustName.Text, Convert.ToInt32(txtAccountNo.Text), 'C'); // creating Commercial customer object
                    c.CustomerCharge = c.calculateBill(int.Parse(txtKwh.Text));                    //Calculatinga a bill amt of Commercial customer
                    com += c.CustomerCharge;                                                       //Adding new bill charge of Commercial customer to the existing bill amount of Commercial customers
                    txtCommercialType.Text = com.ToString("c");
                }
                if (rdIndustrial.Checked)
                {
                    c = new Industrial(txtCustName.Text, Convert.ToInt32(txtAccountNo.Text), 'I');               // creating Industrial customer object
                    c.CustomerCharge = c.calculateBill(int.Parse(txtOnPeak.Text), (int.Parse(txtOffPeak.Text))); //Calculating a bill amt of Industrial customer
                    ind += c.CustomerCharge;                                                                     //Adding new bill charge of industrial customer to the existing bill amount of industrial customers
                    txtIndutrialType.Text = ind.ToString("c");
                }
                customerList.Add(c);
                DisplayCustomers();
            }
        }
コード例 #3
0
        public async Task <Residential> UpdateAsync(string id, Residential model)
        {
            var docId = new ObjectId(id);
            await _mongoResidentialCollection.ReplaceOneAsync(m => m.Id == docId, model);

            return(await GetByIdAsync(id));
        }
コード例 #4
0
        public void developed_property_cant_be_mortgaged()
        {
            _residentialProperty = NewResidential();
            _residentialProperty.AddHouse();

            Assert.IsFalse(_residentialProperty.MortgageProperty());
        }
コード例 #5
0
        //set data to an object base on classification
        private Classification SetClass(string classStr)
        {
            switch (classStr)
            {
            case "residential":
                Residential res = new Residential();
                res.prev       = Double.Parse(tbPrev.Text);
                res.pres       = Double.Parse(tbPres.Text);
                res.days       = Int32.Parse(tbRdays.Text);
                res.addedPrice = Int32.Parse(tbRadded.Text);
                res.price      = Int32.Parse(tbRprice.Text);
                return(res);

            case "commercial":
                Commercial com = new Commercial();
                com.prev       = Double.Parse(tbPrev.Text);
                com.pres       = Double.Parse(tbPres.Text);
                com.days       = Int32.Parse(tbCdays.Text);
                com.addedPrice = Int32.Parse(tbCadded.Text);
                com.price      = Int32.Parse(tbCprice.Text);
                return(com);

            default:
                MessageBox.Show(classStr + " Not implemeted yet");
                return(new Classification());
            }
        }
コード例 #6
0
        public void Location_RandomFullConstructor()
        {
            for (int j = 0; j < 100; j++)
            {
                int testSize  = rnd.Next(1, 10000);
                int maxItems  = rnd.Next(1, 10000);
                int maxAmount = rnd.Next(1, 10000);
                l.GenerateSubLocations(testSize, maxItems, maxAmount);
                Sublocation last = new Residential();

                Assert.IsFalse(l.GetVisited(), "New Location should not be visited");
                Assert.IsTrue(l.IsCurrentSublocationNull(), "Current sublocation should be null");
                Assert.AreEqual(null, l.GetCurrentSubLocation(), "Current Sublocation should be null");

                Assert.AreEqual(testSize, l.GetSize(), "Size should be " + testSize);
                for (int i = 1; i < testSize + 1; i++)
                {
                    Assert.IsTrue(l.SetCurrentSubLocation(i), "Setting to an id which exists (" + i + ") should be succesful");
                    Assert.IsFalse(l.IsCurrentSublocationNull(), "Current sublocation should not be null");

                    last = l.GetCurrentSubLocation();
                    Assert.AreEqual(i, last.GetSublocationID(), "IDs should match");
                    Assert.AreEqual(maxItems, last.GetMaxItems(), "Max items should match");
                    Assert.AreEqual(maxAmount, last.GetMaxAmount(), "Max amount should match");
                }

                Assert.IsFalse(l.SetCurrentSubLocation(testSize + 1), "Setting to an id which does not exists (" + (testSize + 1) + ") should be unsuccesful");
                Assert.IsFalse(l.IsCurrentSublocationNull(), "Current sublocation should not be null");
                Assert.AreEqual(last, l.GetCurrentSubLocation(), "Current Sublocation should have remained the same");
            }
        }
コード例 #7
0
        public void Location_GenerateFixedSize()
        {
            int testSize = 6;

            l = new Location();
            l.GenerateSubLocations(testSize);
            Sublocation last = new Residential();

            Assert.IsFalse(l.GetVisited(), "New Location should not be visited");
            Assert.IsTrue(l.IsCurrentSublocationNull(), "Current sublocation should be null");
            Assert.AreEqual(null, l.GetCurrentSubLocation(), "Current Sublocation should be null");

            Assert.AreEqual(testSize, l.GetSize(), "Size should be " + testSize);
            for (int i = 1; i < testSize + 1; i++)
            {
                Assert.IsTrue(l.SetCurrentSubLocation(i), "Setting to an id which exists (" + i + ") should be succesful");
                Assert.IsFalse(l.IsCurrentSublocationNull(), "Current sublocation should not be null");

                last = l.GetCurrentSubLocation();
                Assert.AreEqual(i, last.GetSublocationID(), "IDs should match");
            }

            Assert.IsFalse(l.SetCurrentSubLocation(testSize + 1), "Setting to an id which does not exists (" + (testSize + 1) + ") should be unsuccesful");
            Assert.IsFalse(l.IsCurrentSublocationNull(), "Current sublocation should not be null");
            Assert.AreEqual(last, l.GetCurrentSubLocation(), "Current Sublocation should have remained the same");
        }
コード例 #8
0
ファイル: TSublocation.cs プロジェクト: arpond/longRoadHome
        public void Residential_Scavenge()
        {
            for (int i = 0; i < 1000; i++)
            {
                items = new List <Item>();
                for (int j = 1; j < 21; j++)
                {
                    Item tmp = new Item(StringMaker.makeItemStr(j));
                    items.Add(tmp);
                }
                res = new Residential(1, rnd.Next(1, 10), rnd.Next(1, 10));
                var ids   = new List <int>();
                var found = res.Scavenge(items);
                Assert.IsTrue(res.GetScavenged(), "Should be scavenged");
                Assert.IsTrue(res.GetMaxItems() >= found.Count, "Items found should not exceed max");
                Assert.IsTrue(found.Count > 0, "Should be at least one item");
                foreach (Item item in found)
                {
                    Assert.IsFalse(ids.Contains(item.GetID()), "ID should not be in the list already");

                    ids.Add(item.GetID());
                    Assert.IsTrue(res.GetMaxAmount() >= item.GetAmount(), "Items found should not have more instances max");
                }

                found = res.Scavenge(items);
                Assert.IsTrue(found.Count == 0, "Should be no items in list");
            }
        }
        public void TestCreate()
        {
            ResidentialFactory rf = new ResidentialFactory();
            Residential        r  = rf.create("Hotel", 1000, 10, 15, 30);

            Assert.AreEqual("Hotel", r.getName());
        }
コード例 #10
0
        public void rent_for_mortgaged_property_is_zero()
        {
            _residentialProperty = NewResidential();
            _residentialProperty.IsMortgaged = true;
            var rentForMortgagedProperty = _residentialProperty.GetRent();

            Assert.AreEqual(Decimal.Zero, rentForMortgagedProperty);
        }
コード例 #11
0
 public void ProcessResidentialAsVacant(Residential residentialNowVacant)
 {
     if (_residentialBuildings.Contains(residentialNowVacant))
     {
         _residentialBuildings.Remove(residentialNowVacant);
         _vacantResidentialBuildings.Add(residentialNowVacant);
     }
 }
コード例 #12
0
        public void rent_for_mortgaged_property_is_zero()
        {
            _residentialProperty             = NewResidential();
            _residentialProperty.IsMortgaged = true;
            var rentForMortgagedProperty = _residentialProperty.GetRent();

            Assert.AreEqual(Decimal.Zero, rentForMortgagedProperty);
        }
コード例 #13
0
        public void player_doesnt_own_properties()
        {
            Board.Access().ResetBoard();
            var property = new Residential();

            _gameOfMonopoly.BuyHouse(_player1, property, true);

            Assert.AreEqual(0, property.GetHouseCount());
        }
コード例 #14
0
        public void rent_for_property_with_one_house_is_correct()
        {
            _residentialProperty = NewResidential();
            _residentialProperty.AddHouse();
            const decimal rentPlusOneHouse = 28;
            var           rentWithHouse    = _residentialProperty.GetRent();

            Assert.AreEqual(rentPlusOneHouse, rentWithHouse);
        }
コード例 #15
0
        public void rent_for_property_with_one_house_is_correct()
        {
            _residentialProperty = NewResidential();
            _residentialProperty.AddHouse();
            const decimal rentPlusOneHouse = 28;
            var rentWithHouse = _residentialProperty.GetRent();

            Assert.AreEqual(rentPlusOneHouse, rentWithHouse);
        }
コード例 #16
0
        public void nonmortgaged_property_cant_be_unmortgaged()
        {
            _residentialProperty = NewResidential();

            // Shouldn't be mortgaged
            Assert.IsFalse(_residentialProperty.IsMortgaged);

            // So we shouldn't be able to unmortgage it
            Assert.IsFalse(_residentialProperty.UnmortgageProperty());
        }
コード例 #17
0
 public void testResidential()
 {
     //create instance of factory
     ResidentialFactory f = new ResidentialFactory();
     //create instance from factory
     Residential p = f.create("Residential", 50, 50, 50);
     //check that it is right type
     Type t = new Residential().GetType();
     Assert.IsInstanceOfType(t, p);
 }
コード例 #18
0
        public void TestGet()
        {
            Residential r = new Residential();

            Assert.AreEqual(50, r.getHouseCost());
            Assert.AreEqual(0, r.getHouseCount());
            Assert.AreEqual(50, r.getRent());
            Assert.AreEqual(200, r.getPrice());
            Assert.AreEqual(4, Residential.getMaxHouses());
        }
コード例 #19
0
        public async Task <Residential> UpdateAsync(string id, Residential model)
        {
            var cacheKey = $"{CacheKey.ResidentialCacheKey}{id}";

            if (_cache.ContainsKey(cacheKey))
            {
                _cache.Clear <Residential>(cacheKey);
            }
            return(await _residentialDal.UpdateAsync(id, model));
        }
コード例 #20
0
        public void player_in_jail()
        {
            var property = new Residential();

            _player1.IsInJail = true;

            _gameOfMonopoly.BuyHouse(_player1, property, true);

            Assert.AreEqual(0, property.GetHouseCount());
        }
        public void TestAddAndReducehotel()
        {
            Residential r = new Residential();
            Player      p = new Player("Tom", 1000);

            r.setOwner(ref p);
            r.addHotel();
            Assert.AreEqual(1, r.getHotelCount());
            r.reduceHotel();
            Assert.AreEqual(0, r.getHotelCount());
        }
コード例 #22
0
 public LaterGrowth()
 {
     city            = GameObject.Find("City").GetComponent <City>();
     industrial      = new Industrial();
     commercial      = new Commercial();
     residential     = new Residential();
     blockHelper     = new BlockHelper(city, industrial, commercial, residential);
     maxDist         = 0.1f;
     minStreetLength = 9f;
     maxStreetLength = 15f;
 }
コード例 #23
0
        public void test_residential()
        {
            //create instance of factory
            ResidentialFactory f = new ResidentialFactory();
            //create instance from factory
            Residential p = f.create("Residential", 50, 50, 50, "Red");
            //check that it is right type
            Type t = new Residential().GetType();

            Assert.IsInstanceOfType(t, p);
        }
コード例 #24
0
        public void mortgaged_property_cant_be_mortgaged_again()
        {
            _residentialProperty = NewResidential();

            _residentialProperty.MortgageProperty();

            // Should now be mortgaged after mortgaging
            Assert.IsTrue(_residentialProperty.IsMortgaged);

            // Trying to mortgage again should return false
            Assert.IsFalse(_residentialProperty.MortgageProperty());
        }
コード例 #25
0
        public void no_houses_left()
        {
            var property = new Residential();

            Board.Access().Houses = 0;

            _gameOfMonopoly.BuyHouse(_player1, property, true);

            Assert.AreEqual(0, property.GetHouseCount());

            Board.Access().ResetBoard();
        }
コード例 #26
0
        public void property_is_mortgaged()
        {
            var property = new Residential();

            property.SetOwner(ref _player1);
            property.MortgageProperty();

            Board.Access().AddProperty(property);

            _gameOfMonopoly.BuyHouse(_player1, property, true);

            Assert.AreEqual(0, property.GetHouseCount());
        }
コード例 #27
0
        public void player_doesnt_own_property_with_house()
        {
            Board.Access().ResetBoard();
            var property = new Residential("Test");

            property.SetOwner(ref _player1);

            Board.Access().AddProperty(property);

            _gameOfMonopoly.SellHouse(_player1);

            Assert.Pass();
        }
コード例 #28
0
        public void adding_house()
        {
            Board.Access().ResetBoard();

            var property = new Residential("Test");

            property.SetOwner(ref _player1);
            Board.Access().AddProperty(property);

            _gameOfMonopoly.BuyHouse(_player1, property, true);

            Assert.AreEqual(1, property.GetHouseCount());
        }
コード例 #29
0
        public void adding_hotel()
        {
            Board.Access().ResetBoard();
            _residentialProperty = NewResidential();

            for (var i = 0; i <= 4; i++)
            {
                _residentialProperty.AddHouse();
            }

            Assert.AreEqual(0, _residentialProperty.GetHouseCount());
            Assert.AreEqual(32, Board.Access().Houses);
            Assert.IsTrue(_residentialProperty.HasHotel);
        }
コード例 #30
0
        public async Task <bool> CreateAsync(Residential model)
        {
            try
            {
                await _mongoResidentialCollection.InsertOneAsync(model);

                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine("Something went wrong: ", e);
                return(false);
            }
        }
コード例 #31
0
        public void player_doesnt_own_all_properties_of_colour()
        {
            var property  = new Residential("Test");
            var property2 = new Residential("Test2");

            property.SetOwner(ref _player1);

            Board.Access().AddProperty(property);
            Board.Access().AddProperty(property2);

            _gameOfMonopoly.BuyHouse(_player1, property, true);

            Assert.AreEqual(0, property.GetHouseCount());
        }
コード例 #32
0
        public void property_with_hotel()
        {
            Board.Access().ResetBoard();
            _residentialProperty = NewResidential();
            Board.Access().AddProperty(_residentialProperty);
            // Multiplied by 5 houses is the expected hotel rent cost
            var expectedRent = _residentialProperty.GetRent() + (_residentialProperty.GetRent() * 5);

            _residentialProperty.HasHotel = true;

            var actualRent = _residentialProperty.GetRent();

            Assert.AreEqual(expectedRent, actualRent);
        }
コード例 #33
0
        public void rent_is_doubled_for_undeveloped_prop_single_owner_colour()
        {
            Board.Access().ResetBoard();
            var player = new Player("Josh");
            _residentialProperty = NewResidential();
            _residentialProperty.SetOwner(ref player);
            
            Board.Access().AddProperty(_residentialProperty);

            const decimal orginalRent = 14;
            const decimal expectedRent = orginalRent*2;
            var actualRent = _residentialProperty.GetRent();

            Assert.AreEqual(expectedRent, actualRent);
        }
コード例 #34
0
        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);
        }
コード例 #35
0
        public void TestLandOn()
        {
            Player playerone = new Player();
            Player playertwo = new Player();
            Board theboard = new Board();

            Residential theproperty = new Residential("Test Property",100,20,30);
            theproperty.setOwner(ref playerone);

            theproperty.isMortgaged = true;
            Board.access().addPlayer(playerone);
            Board.access().addPlayer(playertwo);
            Board.access().addProperty(theproperty);

            playertwo.setLocation(0, false);

            theproperty.landOn(ref playertwo);
        }
コード例 #36
0
        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());
        }
コード例 #37
0
 public void BeforeAll()
 {
     _residentialProperty = _residentialFactory.create("Cape Reinga Lighthouse", 140, 14, 100, "Red");
     _residentialProperty.GetHouseCost();
 }
コード例 #38
0
        public void player_doesnt_own_property_with_house()
        {
            Board.Access().ResetBoard();
            var property = new Residential("Test");
            property.SetOwner(ref _player1);

            Board.Access().AddProperty(property);

            _gameOfMonopoly.SellHouse(_player1);

            Assert.Pass();
        }
コード例 #39
0
        public void selling_house()
        {
            Board.Access().ResetBoard();

            var property = new Residential("Test");
            property.SetOwner(ref _player1);
            property.AddHouse();

            var playersBalanceBefore = _player1.GetBalance();
            var expectedIncreaseAmount = property.GetHouseCost()/2;
            
            Board.Access().AddProperty(property);

            _gameOfMonopoly.SellHouse(_player1, property);

            // Players balance should go up by half house cost
            Assert.AreEqual(playersBalanceBefore + expectedIncreaseAmount, _player1.GetBalance());
            // Property shouldn't have house anymore
            Assert.AreEqual(0, property.GetHouseCount());
            // Board's houses should be back to full
            Assert.AreEqual(32, Board.Access().Houses);
        }
コード例 #40
0
        public void adding_hotel()
        {
            Board.Access().ResetBoard();
            _residentialProperty = NewResidential();

            for (var i = 0; i <= 4; i++)
            {
                _residentialProperty.AddHouse();
            }

            Assert.AreEqual(0, _residentialProperty.GetHouseCount());
            Assert.AreEqual(32, Board.Access().Houses);
            Assert.IsTrue(_residentialProperty.HasHotel);
        }
コード例 #41
0
        public void nonmortgaged_property_cant_be_unmortgaged()
        {
            _residentialProperty = NewResidential();

            // Shouldn't be mortgaged
            Assert.IsFalse(_residentialProperty.IsMortgaged);

            // So we shouldn't be able to unmortgage it
            Assert.IsFalse(_residentialProperty.UnmortgageProperty());
        }
コード例 #42
0
        public void player_doesnt_own_all_properties_of_colour()
        {
            var property = new Residential("Test");
            var property2 = new Residential("Test2");

            property.SetOwner(ref _player1);

            Board.Access().AddProperty(property);
            Board.Access().AddProperty(property2);

            _gameOfMonopoly.BuyHouse(_player1, property, true);

            Assert.AreEqual(0, property.GetHouseCount());
        }
コード例 #43
0
 public void property_has_house_after_adding_house()
 {
     _residentialProperty = NewResidential();
     _residentialProperty.AddHouse();
     Assert.IsTrue(_residentialProperty.GetHouseCount() == 1);
 }
コード例 #44
0
        public void player_doesnt_own_properties()
        {
            Board.Access().ResetBoard();
            var property = new Residential();

            _gameOfMonopoly.BuyHouse(_player1, property, true);

            Assert.AreEqual(0, property.GetHouseCount());
        }
コード例 #45
0
        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);
        }
コード例 #46
0
        public void player_in_jail()
        {
            var property = new Residential();
            _player1.IsInJail = true;

            _gameOfMonopoly.BuyHouse(_player1, property, true);

            Assert.AreEqual(0, property.GetHouseCount());
        }
コード例 #47
0
        public void no_houses_left()
        {
            var property = new Residential();
            Board.Access().Houses = 0;

            _gameOfMonopoly.BuyHouse(_player1, property, true);

            Assert.AreEqual(0, property.GetHouseCount());

            Board.Access().ResetBoard();
        }
コード例 #48
0
        public void developed_property_cant_be_mortgaged()
        {
            _residentialProperty = NewResidential();
            _residentialProperty.AddHouse();

            Assert.IsFalse(_residentialProperty.MortgageProperty());
        }
コード例 #49
0
        public void mortgaged_property_cant_be_mortgaged_again()
        {
            _residentialProperty = NewResidential();

            _residentialProperty.MortgageProperty();

            // Should now be mortgaged after mortgaging
            Assert.IsTrue(_residentialProperty.IsMortgaged);

            // Trying to mortgage again should return false
            Assert.IsFalse(_residentialProperty.MortgageProperty());
        }
コード例 #50
0
        public void property_cant_be_developed_further()
        {
            Board.Access().ResetBoard();

            var property = new Residential("Test");
            var property2 = new Residential("Test2");
            property.SetOwner(ref _player1);
            property2.SetOwner(ref _player1);
            Board.Access().AddProperty(property);
            Board.Access().AddProperty(property2);

            property.AddHouse();

            _gameOfMonopoly.BuyHouse(_player1, property, true);

            Assert.AreEqual(1, property.GetHouseCount());
        }
コード例 #51
0
        public void five_houses_equates_to_hotel()
        {
            _residentialProperty = NewResidential();

            // Shouldn't have houses or hotel to start with
            Assert.IsFalse(_residentialProperty.HasHotel);
            Assert.AreEqual(0, _residentialProperty.GetHouseCount());

            for (var i = 0; i <= 4; i++)   
            {
                _residentialProperty.AddHouse();
            }

            Assert.IsTrue(_residentialProperty.HasHotel);
        }
コード例 #52
0
        public void no_hotels_left()
        {
            Board.Access().ResetBoard();
            Board.Access().Hotels = 0;

            var property = new Residential("Test");
            property.SetOwner(ref _player1);

            for (var i = 0; i <= 3; i++)
            {
                property.AddHouse();
            }

            Board.Access().AddProperty(property);

            _gameOfMonopoly.BuyHouse(_player1, property, true);

            Assert.AreEqual(4, property.GetHouseCount());
            Assert.IsFalse(property.HasHotel);
        }
コード例 #53
0
        public void property_with_hotel()
        {
            Board.Access().ResetBoard();
            _residentialProperty = NewResidential();
            Board.Access().AddProperty(_residentialProperty);
            // Multiplied by 5 houses is the expected hotel rent cost
            var expectedRent = _residentialProperty.GetRent() + (_residentialProperty.GetRent() * 5);

            _residentialProperty.HasHotel = true;

            var actualRent = _residentialProperty.GetRent();

            Assert.AreEqual(expectedRent, actualRent);
        }
コード例 #54
0
        public void adding_house()
        {
            Board.Access().ResetBoard();

            var property = new Residential("Test");
            property.SetOwner(ref _player1);
            Board.Access().AddProperty(property);

            _gameOfMonopoly.BuyHouse(_player1, property, true);

            Assert.AreEqual(1, property.GetHouseCount());
        }
コード例 #55
0
        public void property_is_mortgaged()
        {
            var property = new Residential();
            property.SetOwner(ref _player1);
            property.MortgageProperty();

            Board.Access().AddProperty(property);

            _gameOfMonopoly.BuyHouse(_player1, property, true);

            Assert.AreEqual(0, property.GetHouseCount());
        }
コード例 #56
0
        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());
        }