public void GetTotalPayroll_Salesman_TotalSalary() { // Arrange var company = new Company(); var john = company.Add <Manager>("John"); var jack = company.Add <Salesman>("John"); john.AddSubordinate(jack); var james = company.Add <Salesman>("James"); jack.AddSubordinate(james); var jo = company.Add <Salesman>("Jo"); jack.AddSubordinate(jo); var jastin = company.Add <Manager>("Jastin"); jo.AddSubordinate(jastin); var totalSalary = company.Employees.Sum(e => e.GetSalary()); // Act var payroll = company.GetTotalPayroll(); // Assert Assert.AreEqual(totalSalary, payroll); }
public void Add_3Employees_3() { var company = new Company(); company.Add <Manager>("John"); company.Add <Employee>("Jack"); company.Add <Salesman>("James"); Assert.AreEqual(3, company.Employees.Count()); }
public void GetTotalPayroll_3Employees_TotalSalary() { var company = new Company(); var totalSalary = company.Add <Manager>("John").GetSalary() + company.Add <Employee>("Jack").GetSalary() + company.Add <Salesman>("James").GetSalary(); var payroll = company.GetTotalPayroll(); Assert.AreEqual(totalSalary, payroll); }
public void Remove_1Subordinate_SubordinateRemoved() { var company = new Company(); var subordinate = company.Add <Employee>("Jack"); var manager = company.Add <Manager>("John"); manager.AddSubordinate(subordinate); company.Remove(subordinate); Assert.IsFalse(manager.HasSubordinate(subordinate)); }
public void FindCorrectFurniture_WhenFindIsCalled() { var company = new Company("Izgrev", "0123456789"); var chair = new Chair("Visage", "Wood", 65, 1.20m, 4); var secondChair = new Chair("Caprize", "Wood", 65, 1.20m, 4); company.Add(chair); company.Add(secondChair); var result = company.Find("Caprize"); Assert.AreEqual(secondChair, result); }
public void Add_3Employees2Removed_1() { var company = new Company(); var manager = company.Add <Manager>("John"); company.Add <Employee>("Jack"); var salesman = company.Add <Salesman>("James"); company.Remove(manager); company.Remove(salesman); Assert.AreEqual(1, company.Employees.Count()); }
public void updateCompanyCommand(object obj) { if (companyDB.updateCompany(Comp_ID, ManagerName, CivilNumber, CompanyName, ContractNumber, ReferenceNumber, AutomatedNumber, Area, block, street, phone, Governate, BusinessField, ManagerNameEng, CompanyNameEng, BusinessFieldEng)) { var found = Company.FirstOrDefault(x => x.Comp_ID == Comp_ID); Company.Remove(found); Company.Add(new Models.CompanyModel { Comp_ID = Comp_ID, ManagerName = ManagerName, CivilNumber = CivilNumber, CompanyName = CompanyName, ContractNumber = ContractNumber, ReferenceNumber = ReferenceNumber, AutomatedNumber = AutomatedNumber, Area = Area, block = block, street = street, phone = phone, Governate = Governate, BusinessField = BusinessField, ManagerNameeng = ManagerNameEng, CompanyNameeng = CompanyNameEng, BusinessFieldEng = BusinessFieldEng }); } }
public HttpResponseMessage add(Company post) { // Check for errors if (post == null) { return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null")); } // Make sure that the data is valid post.name = AnnytabDataValidation.TruncateString(post.name, 100); post.registered_office = AnnytabDataValidation.TruncateString(post.registered_office, 100); post.org_number = AnnytabDataValidation.TruncateString(post.org_number, 100); post.vat_number = AnnytabDataValidation.TruncateString(post.vat_number, 100); post.phone_number = AnnytabDataValidation.TruncateString(post.phone_number, 100); post.mobile_phone_number = AnnytabDataValidation.TruncateString(post.mobile_phone_number, 100); post.email = AnnytabDataValidation.TruncateString(post.email, 100); post.post_address_1 = AnnytabDataValidation.TruncateString(post.post_address_1, 100); post.post_address_2 = AnnytabDataValidation.TruncateString(post.post_address_2, 100); post.post_code = AnnytabDataValidation.TruncateString(post.post_code, 100); post.post_city = AnnytabDataValidation.TruncateString(post.post_city, 100); post.post_country = AnnytabDataValidation.TruncateString(post.post_country, 100); // Add the post Company.Add(post); // Return the success response return(Request.CreateResponse <string>(HttpStatusCode.OK, "The post has been added")); } // End of the add method
public void TestAddRecipe() { Company testCompany = new Company("testco", 1000); Recipe testRecipe = new Recipe(); // Starts at 0 Assert.AreEqual(0, testCompany.recipes.Count); // Add 1 Assert.IsTrue(testCompany.Add(testRecipe)); Assert.AreEqual(1, testCompany.recipes.Count); // Add another Assert.IsTrue(testCompany.Add(testRecipe)); Assert.AreEqual(2, testCompany.recipes.Count); }
protected void BtnAppend_Click(object sender, EventArgs e) { this.m_ClickId = DataConverter.CLng(this.ViewState["ClientId"]); EasyOne.Model.Crm.CompanyInfo companyInfo = new EasyOne.Model.Crm.CompanyInfo(); this.Company1.Action = "add"; this.Company1.CompanyClientId = this.m_ClickId; companyInfo = this.Company1.CompanyInfo; bool flag = false; if (Company.Add(companyInfo)) { flag = Users.UpdateForCompany(companyInfo.CompanyId, this.m_UserName, UserType.Creator, 0); if (flag && (this.m_ClickId > 0)) { flag = Client.UpdateForCompany(this.m_ClickId, companyInfo.CompanyName); } } if (flag) { DynamicPage.WriteSuccessMsg("已经成功注册企业:" + companyInfo.CompanyName + "<br>从现在起,您是这家企业的创建人,拥有这家企业的管理权限(如审核批准其他人的申请)。同时您成为了我们的企业会员,可以享受更多服务!", "../Default.aspx"); } else { DynamicPage.WriteSuccessMsg("<li>添加不成功!</li>"); } }
protected void BtnAppend_Click(object sender, EventArgs e) { if (this.Page.IsValid) { string userName = Convert.ToString(this.ViewState["UserName"]); int clientId = DataConverter.CLng(this.ViewState["ClientId"]); EasyOne.Model.Crm.CompanyInfo companyInfo = new EasyOne.Model.Crm.CompanyInfo(); this.Company1.Action = "add"; this.Company1.CompanyClientId = clientId; companyInfo = this.Company1.CompanyInfo; bool flag = false; if (Company.Add(companyInfo)) { flag = Users.UpdateForCompany(companyInfo.CompanyId, userName, UserType.Creator, 0); if (flag && (clientId > 0)) { flag = Client.UpdateForCompany(clientId, companyInfo.CompanyName); } } if (flag) { AdminPage.WriteSuccessMsg("成功创建了新企业:" + companyInfo.CompanyName + "<br>并将会员 " + userName + " 设为这家企业的创建人,拥有这家企业的管理权限(如审核批准其他人的申请)。", "UserShow.aspx?UserID=" + this.m_UserId); } else { AdminPage.WriteSuccessMsg("<li>添加不成功!</li>"); } } }
public void addCompanyCommand(object obj) { if (companyDB.addCompany(ManagerName, CivilNumber, CompanyName, ContractNumber, ReferenceNumber, AutomatedNumber, Area, block, street, phone, Governate, BusinessField, ManagerNameEng, CompanyNameEng, BusinessFieldEng)) { Company.Add(new Models.CompanyModel { Comp_ID = companyDB.getLastInertedID(), ManagerName = ManagerName, CivilNumber = CivilNumber, CompanyName = CompanyName, ContractNumber = ContractNumber, ReferenceNumber = ReferenceNumber, AutomatedNumber = AutomatedNumber, Area = Area, block = block, street = street, phone = phone, Governate = Governate, BusinessField = BusinessField, ManagerNameeng = ManagerNameEng, CompanyNameeng = CompanyNameEng, BusinessFieldEng = BusinessFieldEng }); } }
/// <summary> /// Recursively links every square touching this one with the given company /// /// Returns the company being linked /// </summary> /// /// <param name="instigator">The square instigating this linking</param> /// <param name="newCompany">The company taking over</param> /// /// <returns>The company being linked</returns> private static Company Link(Square instigator, Company newCompany) { // Add this square to the company newCompany.Add(instigator); // Increment the size of the company newCompany.Size++; // Redraw the frame Game.Refresh(); // Get the current player IPlayer player = Game.CurrentPlayer; // If this company is in the active list, it isn't new bool isNew = !ActiveCompanies.Any(c => c.Name.Equals(newCompany.Name)); // If it is new, add it to the list of active companies if (isNew) { ActiveCompanies.Add(newCompany); } // If this company isn't marked as placed if (!newCompany.IsPlaced) { // Log that the company is being formed LogMaster.Log($"{player.Name} has formed the {newCompany.Name} company."); // And give the player the amount of money they need to get 1 "free" share player.GiveMoney(newCompany.GetPrice()); player.BuyShare(newCompany, true); // Mark the company as placed newCompany.IsPlaced = true; } // Check if the game is enable Game.EndGameCheck(); // Set the company associated with this square to this company instigator.SetCompany(newCompany); // Check the boundary squares. If there is a square that needs to be taken over, take it over if (instigator.LeftSquare != null && instigator.LeftSquare.Company != newCompany && instigator.LeftSquare.State > SquareState.Placeable) { newCompany = Link(instigator.LeftSquare, newCompany); } if (instigator.RightSquare != null && instigator.RightSquare.Company != newCompany && instigator.RightSquare.State > SquareState.Placeable) { newCompany = Link(instigator.RightSquare, newCompany); } if (instigator.TopSquare != null && instigator.TopSquare.Company != newCompany && instigator.TopSquare.State > SquareState.Placeable) { newCompany = Link(instigator.TopSquare, newCompany); } if (instigator.BottomSquare != null && instigator.BottomSquare.Company != newCompany && instigator.BottomSquare.State > SquareState.Placeable) { newCompany = Link(instigator.BottomSquare, newCompany); } return(newCompany); }
public void ThrowArgumentNullException_WhenPassedNullParam() { var validName = "Pesho"; var validRegistrationNumber = "1234567890"; var sut = new Company(validName, validRegistrationNumber); Assert.ThrowsException <ArgumentNullException>(() => sut.Add(null)); }
public void GetTotalPayroll_1Employee_Salary() { var company = new Company(); var salary = company.Add <Employee>("Jack").GetSalary(); var payroll = company.GetTotalPayroll(); Assert.AreEqual(salary, payroll); }
public void ReturnExpectedSortedByModelString_WhenCatalogIsCalledWithMoreThanOneFurniture() { var company = new Company("Izgrev", "0123456789"); var chair = new Chair("Avangard", "Wood", 65, 1.20m, 4); var secondChair = new Chair("Caprize", "Wood", 65, 1.00m, 3); company.Add(secondChair); company.Add(chair); var newLine = Environment.NewLine; string expected = "Izgrev - 0123456789 - 2 furnitures" + newLine + "Type: Chair, Model: Avangard, Material: Wood, Price: 65, Height: 1,20Legs: 4" + newLine + "Type: Chair, Model: Caprize, Material: Wood, Price: 65, Height: 1,00Legs: 3"; Assert.AreEqual(expected, company.Catalog()); }
public void ThrowNullReferenceException_WhenFindIsCalledWithNullValue() { var company = new Company("Izgrev", "0123456789"); var chair = new Chair("Visage", "Wood", 65, 1.20m, 4); company.Add(chair); Assert.Throws <NullReferenceException>(() => company.Find(null)); }
public void TestAddBrewery() { Company testCompany = new Company("testco", 1000); Brewery testBrewery = new Brewery(); Location testLocation1 = new Location("testloc1", new int[] { 1, 1 }); Location testLocation2 = new Location("testloc2", new int[] { 2, 2 }); // Successfully add a brewery Assert.IsTrue(testCompany.Add(testBrewery, testLocation1)); // Can't add to the same location Assert.IsFalse(testCompany.Add(testBrewery, testLocation1)); // Still only 1 Assert.AreEqual(1, testCompany.breweries.Count); // Can add to a new location Assert.IsTrue(testCompany.Add(testBrewery, testLocation2)); }
public void AddFurniture_WhenAddIsCalled() { var company = new Company("Izgrev", "0123456789"); var chair = new Chair("Visage", "Wood", 65, 1.20m, 4); company.Add(chair); Assert.AreEqual(1, company.Furnitures.Count); }
public void ThrowArgumentNullException_WhenFurnitureIsNull() { // Arrange var companyName = "somecompanyname"; var registrationNumber = "1234567890"; var sut = new Company(companyName, registrationNumber); // Act & Assert Assert.ThrowsException <ArgumentNullException>(() => sut.Add(null)); }
public void AddFurnitureToLocalCollection_WhenPassedValidParam() { var validName = "Pesho"; var validRegistrationNumber = "1234567890"; var furnitureStub = new Mock <IFurniture>(); var sut = new Company(validName, validRegistrationNumber); sut.Add(furnitureStub.Object); Assert.IsTrue(sut.Furnitures.Count == 1 && sut.Furnitures.Contains(furnitureStub.Object)); }
public void Add_Ut() { Company dpCompany = new Company(); SETUP_Company mdlCompany = new SETUP_Company(); mdlCompany.Comp_Desc = "Demo Company4"; mdlCompany.Comp_Code = "0004"; mdlCompany.Comp_EMail = "*****@*****.**"; mdlCompany.Comp_Mobile1 = "03346024022"; mdlCompany.Comp_Address1 = "Test Address4"; dpCompany.Add(mdlCompany); }
public void TakeAllRouts() { Classes.Clear(); Classes.Add(new FlightsModel { clas = "Бизнес" }); Classes.Add(new FlightsModel { clas = "Эконом" }); Routs.Clear(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandText = @"select id_route,s1.town,s2.town,length_of_route from route inner join airport s1 on s1.nameAirport = route.id_airport_from inner join airport s2 on s2.nameAirport = route.id_airport_to"; sqlCommand.Connection = DBConnection.DBConnection.SqlConnection; SqlDataReader reader = sqlCommand.ExecuteReader(); foreach (var i in reader) { Routs.Add(new RouteModel { IdRoute = reader.GetInt32(0), airport_From_To = $"{reader.GetString(1)} - {reader.GetString(2)}", length_of_route = Convert.ToString(reader.GetInt32(3)) }); } reader.Close(); Aircrafts.Clear(); sqlCommand.CommandText = @"select * from aircrafts"; sqlCommand.Connection = DBConnection.DBConnection.SqlConnection; SqlDataReader reader2 = sqlCommand.ExecuteReader(); foreach (var i in reader2) { Aircrafts.Add(new AircraftModel { name_aircraft = reader2.GetString(0), count_of_seats = reader2.GetInt32(1).ToString(), speed = reader2.GetInt32(2).ToString() }); } reader2.Close(); Company.Clear(); sqlCommand.CommandText = @"select * from company"; sqlCommand.Connection = DBConnection.DBConnection.SqlConnection; SqlDataReader reader3 = sqlCommand.ExecuteReader(); foreach (var i in reader3) { Company.Add(new CompanyModel { company_name = reader3.GetString(0), cost_of_1km = reader3.GetFloat(1).ToString(), cost_of_business = reader3.GetFloat(2).ToString(), cost_of_econom = reader3.GetFloat(3).ToString() }); } reader3.Close(); }
public void AddFurnitureToCollection_WhenPassedCorrectData() { // Arrange var companyName = "somecompanynamehere"; var registrationNumber = "1234567890"; var furnitureStub = new Mock <IFurniture>(); var sut = new Company(companyName, registrationNumber); // Act sut.Add(furnitureStub.Object); // Assert Assert.IsTrue(sut.Furnitures.Count == 1); }
public void ReturnExpectedString_WhenCatalogIsCalledWithOneFurniture() { var company = new Company("Izgrev", "0123456789"); var chair = new Chair("Visage", "Wood", 65, 1.20m, 4); company.Add(chair); var newLine = Environment.NewLine; string expected = "Izgrev - 0123456789 - 1 furniture" + newLine + "Type: Chair, Model: Visage, Material: Wood, Price: 65, Height: 1,20Legs: 4"; Assert.AreEqual(expected, company.Catalog()); }
public ActionResult Add(SETUP_Company company) { Company dpCompany = new Company(); int id = dpCompany.Add(company); if (id > 0) { return(RedirectToAction("Index", "Company")); } else { TempData["error"] = "Opps! Somthing went wrong!"; return(RedirectToAction("Add", "Company")); } }
private void btnAddCompany_Click(object sender, RoutedEventArgs e) { try { if (!ValidateCompany()) { return; } Company c = new Company { Name = tbCompanyName.Text }; c.Add(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void BindData() { var companies = CompanyBll.GetAllList(x => x.IsActive == true); foreach (var item in companies) { Company.Add(new CompanyModel() { Id = item.Id, Name = item.Name, Number = item.Number }); } var locations = LocationBll.GetAllList(x => x.IsActive == true); foreach (var item in locations) { Location.Add(new LocationModel() { Id = item.Id, Name = item.Name }); } }
private async void Save(object sender, EventArgs e) { _this.Name = txtName.Text; _this.Street = txtStreet.Text; _this.Street2 = txtStreet2.Text; _this.BuildingNo = txtBuildingNo.Text; _this.ZipCode = txtZipCode.Text; _this.City = txtCity.Text; _this.Country = txtCountry.Text; _this.TypeId = Convert.ToInt32(cmbType.SelectedValue.ToString()); _this.IsArchived = cboxArchived.CheckState.CheckboxStateToNullableBool(); try { Looper.Show(this); if (mode == 1) { _this.CreatedBy = RuntimeSettings.UserId; _this.CreatedOn = DateTime.Now; if (await _this.Add()) { mode = 2; this.Text = "Szczegóły firmy"; } } else if (mode == 2) { _this.Edit(); } }catch (Exception ex) { } finally { Looper.Hide(); } }
public ActionResult edit(FormCollection collection) { // Get the current domain Domain currentDomain = Tools.GetCurrentDomain(); ViewBag.CurrentDomain = currentDomain; // Get the return url string returnUrl = collection["returnUrl"]; ViewBag.QueryParams = new QueryParams(returnUrl); // Check if the administrator is authorized if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor" }) == true) { ViewBag.AdminSession = true; } else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true) { ViewBag.AdminSession = true; ViewBag.AdminErrorCode = 1; ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC"); return View("index"); } else { // Redirect the user to the start page return RedirectToAction("index", "admin_login"); } // Get all the form values Int32 id = Convert.ToInt32(collection["txtId"]); string name = collection["txtName"]; string registered_office = collection["txtRegisteredOffice"]; string org_number = collection["txtOrgNumber"]; string vat_number = collection["txtVatNumber"]; string phone_number = collection["txtPhoneNumber"]; string mobile_phone_number = collection["txtMobilePhoneNumber"]; string email = collection["txtEmail"]; string post_address_1 = collection["txtPostAddress1"]; string post_address_2 = collection["txtPostAddress2"]; string post_code = collection["txtPostCode"]; string post_city = collection["txtPostCity"]; string post_country = collection["txtPostCountry"]; // Get the default admin language id Int32 adminLanguageId = currentDomain.back_end_language; // Get translated texts KeyStringList translatedTexts = StaticText.GetAll(adminLanguageId, "id", "ASC"); // Get the company Company company = Company.GetOneById(id); // Check if the company exists if (company == null) { // Create an empty company company = new Company(); } // Update values company.name = name.Length > 100 ? name.Substring(0, 100) : name; company.registered_office = registered_office.Length > 100 ? registered_office.Substring(0, 100) : registered_office; company.org_number = org_number.Length > 100 ? org_number.Substring(0, 100) : org_number; company.vat_number = vat_number.Length > 100 ? vat_number.Substring(0, 100) : vat_number; company.phone_number = phone_number.Length > 100 ? phone_number.Substring(0, 100) : phone_number; company.mobile_phone_number = mobile_phone_number.Length > 100 ? mobile_phone_number.Substring(0, 100) : mobile_phone_number; company.email = email.Length > 100 ? email.Substring(0, 100) : email; company.post_address_1 = post_address_1.Length > 100 ? post_address_1.Substring(0, 100) : post_address_1; company.post_address_2 = post_address_2.Length > 100 ? post_address_2.Substring(0, 100) : post_address_2; company.post_code = post_code.Length > 100 ? post_code.Substring(0, 100) : post_code; company.post_city = post_city.Length > 100 ? post_city.Substring(0, 100) : post_city; company.post_country = post_country.Length > 100 ? post_country.Substring(0, 100) : post_country; // Create a error message string errorMessage = string.Empty; // Check if there is errors if (errorMessage == string.Empty) { // Check if we should add or update the company if (company.id == 0) { // Add the company Company.Add(company); } else { // Update the company Company.Update(company); } // Redirect the user to the list return Redirect("/admin_companies" + returnUrl); } else { // Set form values ViewBag.ErrorMessage = errorMessage; ViewBag.Company = company; ViewBag.TranslatedTexts = translatedTexts; ViewBag.ReturnUrl = returnUrl; // Return the edit view return View("edit"); } } // End of the edit method