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")); }
//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(); } }
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)); }
public void developed_property_cant_be_mortgaged() { _residentialProperty = NewResidential(); _residentialProperty.AddHouse(); Assert.IsFalse(_residentialProperty.MortgageProperty()); }
//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()); } }
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"); } }
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"); }
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()); }
public void rent_for_mortgaged_property_is_zero() { _residentialProperty = NewResidential(); _residentialProperty.IsMortgaged = true; var rentForMortgagedProperty = _residentialProperty.GetRent(); Assert.AreEqual(Decimal.Zero, rentForMortgagedProperty); }
public void ProcessResidentialAsVacant(Residential residentialNowVacant) { if (_residentialBuildings.Contains(residentialNowVacant)) { _residentialBuildings.Remove(residentialNowVacant); _vacantResidentialBuildings.Add(residentialNowVacant); } }
public void player_doesnt_own_properties() { Board.Access().ResetBoard(); var property = new Residential(); _gameOfMonopoly.BuyHouse(_player1, property, true); Assert.AreEqual(0, property.GetHouseCount()); }
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); }
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()); }
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); }
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()); }
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)); }
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()); }
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; }
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); }
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()); }
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(); }
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()); }
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(); }
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()); }
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); }
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); } }
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()); }
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); }
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); }
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); }
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); }
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()); }
public void BeforeAll() { _residentialProperty = _residentialFactory.create("Cape Reinga Lighthouse", 140, 14, 100, "Red"); _residentialProperty.GetHouseCost(); }
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); }
public void property_has_house_after_adding_house() { _residentialProperty = NewResidential(); _residentialProperty.AddHouse(); Assert.IsTrue(_residentialProperty.GetHouseCount() == 1); }
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()); }
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); }
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); }
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()); }