public void UpdateEmployee_withNonExistentEmployee() { EmployeeEntity employeeEntity = new EmployeeEntity(); Employee employeeToUpate = new Employee(); employeeToUpate.EmployeeId = 199; EmployeeDataEntity employeeDataEntity = new EmployeeDataEntity(); bool result = employeeEntity.UpdateEmployee(employeeToUpate); EmployeeDataEntity.EmployeeBase.Clear(); Assert.IsFalse(result); }
void GetToUpdateEmployeeDetail(Employee employeeToUpdate) { string fullName = employeeToUpdate.FirstName + "." + employeeToUpdate.LastName; Console.WriteLine(ResourceCulture.GetString("UpdateInfo1") + " " + fullName + ResourceCulture.GetString("UpdateInfo2")); CommonEntity commonEntity = new CommonEntity(); bool valid = false; //get input birth valid = false; string inputBirth = null; Console.WriteLine(ResourceCulture.GetString("BirthInputTips")); inputBirth = Console.ReadLine().Trim(); if (inputBirth.Length > 0) { while (!valid) { valid = commonEntity.IsValidBirthday(inputBirth); if (!valid) { Console.WriteLine(ResourceCulture.GetString("BirthInputError")); inputBirth = Console.ReadLine().Trim(); } } employeeToUpdate.Birth = Convert.ToDateTime(inputBirth); } else { employeeToUpdate.Birth = new DateTime(); } //get input address valid = false; string inputAddress = null; Console.WriteLine(ResourceCulture.GetString("AddressInputTips")); inputAddress = Console.ReadLine().Trim(); if (inputAddress.Length > 0) { while (!valid) { valid = commonEntity.IsValidAddress(inputAddress); if (!valid) { Console.WriteLine(ResourceCulture.GetString("AddressInputError")); inputAddress = Console.ReadLine().Trim(); } } employeeToUpdate.Address = inputAddress; } else { employeeToUpdate.Address = null; } //get input phone valid = false; string inputPhone = null; Console.WriteLine(ResourceCulture.GetString("PhoneInputTips")); inputPhone = Console.ReadLine().Trim(); if (inputPhone.Length > 0) { while (!valid) { valid = commonEntity.IsValidPhone(inputPhone); if (!valid) { Console.WriteLine(ResourceCulture.GetString("PhoneInputError")); inputPhone = Console.ReadLine().Trim(); } } employeeToUpdate.Phone = inputPhone; } else { employeeToUpdate.Phone = null; } //update EmployeeEntity employeeEntity = new EmployeeEntity(); bool result = employeeEntity.UpdateEmployee(employeeToUpdate); if (result) { Console.WriteLine("\n\n" + ResourceCulture.GetString("UpdateSuccessInfo") + "\n"); } else { Console.WriteLine("\n\n" + ResourceCulture.GetString("UpdateFailInfo") + "\n"); } }