public void GetEmployee() { EmployeeOperation e = new EmployeeOperation(); EmployeeModel em = new EmployeeModel(); em.Name = "lalit"; em.Designation = "Developer"; var id = e.AddEmployee(em); // var empRecAdd = e.Get(id.ToString()); // Assert.IsNotNull(empRecAdd); // Assert.AreEqual(empRecAdd.Name, em.Name); List <EmployeeModel> lst = e.GetAll(); int i = lst.Count; Assert.AreEqual(i, id); //e.Get("2"); // em.Id; e.AddEmployee(em); // e.Edit(em); // e.Delete("2"); }
public void Delete_Employ_Response() { this.repo.DeleteElement(Arg.Any <int>(), Constant.FilePath).Returns(new OutputWrapper <EmployeNode>()); var result = new EmployeeOperation(this.repo); var output = result.DeleteEmploye(1, Constant.FilePath); Assert.IsFalse(output.Result.Failure); }
public void DeleteEmployee_WithNonExistentId() { int employeeId = 101; EmployeeOperation employeeOperation = new EmployeeOperation(); bool result = employeeOperation.DeleteEmployee(employeeId); Assert.IsFalse(result); }
public void CheckEmployeeExist_WithNonExistentId() { EmployeeOperation employeeOperation = new EmployeeOperation(); int employeeId = 101; bool result = employeeOperation.CheckEmployeeExist(employeeId); Assert.IsFalse(result); }
public void Clone_test() { Employee clonedEmployee = new Employee(); clonedEmployee.EmployeeId = 199; Employee result = EmployeeOperation.Clone <Employee>(clonedEmployee); Assert.AreEqual(clonedEmployee.EmployeeId, result.EmployeeId); }
public void Add_Employ_Response() { this.repo.SaveElement(Arg.Any <List <EmployeNode> >(), Constant.FilePath).Returns(Task.FromResult(new OutputWrapper <EmployeNode> { Failure = false })); var result = new EmployeeOperation(this.repo); var output = result.AddEmployee(new List <EmployeNode>(), Constant.FilePath); Assert.IsFalse(output.Result.Failure); }
public void UpdateEmployee_WithNonExistentEmployee() { EmployeeOperation employeeOperation = new EmployeeOperation(); Employee employeeItem = new Employee(); employeeItem.EmployeeId = 199; bool result = employeeOperation.UpdateEmployee(employeeItem); Assert.IsFalse(result); }
public void DeleteEmployee_WithExistentId() { int employeeId = 101; EmployeeOperation employeeOperation = new EmployeeOperation(); EmployeeDataEntity employeeDataEntity = new EmployeeDataEntity(); bool result = employeeOperation.DeleteEmployee(employeeId); EmployeeDataEntity.EmployeeBase.Clear(); Assert.IsTrue(result); }
public void GetEmployeeSearchResult_WithNoCondition() { EmployeeOperation employeeOperation = new EmployeeOperation(); Employee employeeConditon = new Employee(); EmployeeDataEntity employeeDataEntity = new EmployeeDataEntity(); List <Employee> listResult = employeeOperation.GetEmployeeSearchResult(employeeConditon); EmployeeDataEntity.EmployeeBase.Clear(); Assert.AreEqual(3, listResult.Count); }
public void CheckEmployeeExist_WithExistentId() { EmployeeOperation employeeOperation = new EmployeeOperation(); int employeeId = 101; EmployeeDataEntity employeeDataEntity = new EmployeeDataEntity(); bool result = employeeOperation.CheckEmployeeExist(employeeId); EmployeeDataEntity.EmployeeBase.Clear(); Assert.IsTrue(result); }
public bool DeleteEmployee(int employeeId) { bool result = new EmployeeOperation().DeleteEmployee(employeeId); if (result) { return(true); } else { return(false); } }
public void GetEmployeeSearchResult_WithNonExistentFirstName() { EmployeeOperation employeeOperation = new EmployeeOperation(); Employee employeeConditon = new Employee(); employeeConditon.FirstName = "test"; EmployeeDataEntity employeeDataEntity = new EmployeeDataEntity(); List <Employee> listResult = employeeOperation.GetEmployeeSearchResult(employeeConditon); EmployeeDataEntity.EmployeeBase.Clear(); Assert.AreEqual(0, listResult.Count); }
public void UpdateEmployee_WithExistentEmployee() { EmployeeOperation employeeOperation = new EmployeeOperation(); Employee employeeItem = new Employee(); employeeItem.EmployeeId = 101; EmployeeDataEntity employeeDataEntity = new EmployeeDataEntity(); bool result = employeeOperation.UpdateEmployee(employeeItem); EmployeeDataEntity.EmployeeBase.Clear(); Assert.IsTrue(result); }
public List <Employee> FuzzySearchEmployee(Employee employeeCondition) { List <Employee> employeeList = new List <Employee>(); employeeList = new EmployeeOperation().GetEmployeeSearchResult(employeeCondition); if (employeeList.Count > 0) { return(employeeList); } else { return(null); } }
static async System.Threading.Tasks.Task Main() { IXMLRepository xmlRepo = new XMLRepository(); IEmployeeOperation employee = new EmployeeOperation(xmlRepo); EmployeDecorator employDeco = new EmployeDecorator(employee); ConsoleKeyInfo cki; Console.WriteLine("Console XML Operation Assignment 2 \r"); Console.WriteLine("------------------------\n"); do { cki = Console.ReadKey(false); Console.WriteLine("Choose an option from the following list:"); Console.WriteLine("\t1 - Add to XML"); Console.WriteLine("\t2 - Print XML"); Console.WriteLine("\t3 - Delete XML Record"); Console.WriteLine("\t4 - Add New Node"); Console.Write("Your option? "); switch (Console.ReadLine()) { case "1": await AddEmployee(employDeco); break; case "2": await GetEmployee(employDeco); break; case "3": await DeleteEmployee(employDeco); break; case "4": await AddNode(); break; } } while (cki.Key != ConsoleKey.Escape); Console.Write("Press any key to close the XML console app..."); Console.ReadKey(); }
public void GetEmployeeSearchResult_WithExistentId() { EmployeeOperation employeeOperation = new EmployeeOperation(); Employee employeeConditon = new Employee(); employeeConditon.EmployeeId = 101; EmployeeDataEntity employeeDataEntity = new EmployeeDataEntity(); List <Employee> listResult = employeeOperation.GetEmployeeSearchResult(employeeConditon); EmployeeDataEntity.EmployeeBase.Clear(); Assert.AreEqual(1, listResult.Count); Assert.AreEqual(101, listResult[0].EmployeeId); }
public void UpdateEmployee_WithFullUpdate() { EmployeeOperation employeeOperation = new EmployeeOperation(); Employee employeeItem = new Employee(); employeeItem.EmployeeId = 101; employeeItem.Address = "updatedPlace"; employeeItem.Birth = Convert.ToDateTime("2016-1-1"); employeeItem.Phone = "13412345678"; EmployeeDataEntity employeeDataEntity = new EmployeeDataEntity(); bool result = employeeOperation.UpdateEmployee(employeeItem); EmployeeDataEntity.EmployeeBase.Clear(); Assert.IsTrue(result); }
public void GetEmployeeSearchResult_WithExistentLastName() { EmployeeOperation employeeOperation = new EmployeeOperation(); Employee employeeConditon = new Employee(); employeeConditon.LastName = "zh"; EmployeeDataEntity employeeDataEntity = new EmployeeDataEntity(); List <Employee> listResult = employeeOperation.GetEmployeeSearchResult(employeeConditon); EmployeeDataEntity.EmployeeBase.Clear(); Assert.AreEqual(2, listResult.Count); Assert.AreEqual("Zhao", listResult[0].LastName); Assert.AreEqual("Zha", listResult[1].LastName); }
public void GetEmployeeSearchResult_WithFullExistentConditon() { EmployeeOperation employeeSearch = new EmployeeOperation(); Employee employeeConditon = new Employee(); employeeConditon.EmployeeId = 101; employeeConditon.LastName = "zh"; employeeConditon.FirstName = "ziv"; EmployeeDataEntity employeeDataEntity = new EmployeeDataEntity(); List <Employee> listResult = employeeSearch.GetEmployeeSearchResult(employeeConditon); EmployeeDataEntity.EmployeeBase.Clear(); Assert.AreEqual(1, listResult.Count); Assert.AreEqual("Zhao", listResult[0].LastName); }
public int AddEmployee_BLL(Employee newEmp) { int rowsAffected = 0; EmployeeOperation operationObj; try { if (validateEmp(newEmp)) { operationObj = new EmployeeOperation(); rowsAffected = operationObj.AddEmployee_DAL(newEmp); } } catch (EmployeeException ex) { throw ex; } catch (SqlException se) { throw se; } catch (Exception ex) { throw ex; } return(rowsAffected); }
public void CreateEmployee_noOtherRecord() { EmployeeOperation emploeeCreation = new EmployeeOperation(); Employee employee = new Employee(); employee.FirstName = "test"; employee.LastName = "demo"; employee.Gender = "M"; employee.Phone = "13454521622"; employee.Address = "Beijing"; employee.Birth = Convert.ToDateTime("1998-1-1"); bool result = emploeeCreation.CreateEmployee(employee); EmployeeDataEntity.EmployeeBase.Clear(); Assert.IsTrue(result); }
public DataTable GetEmployee_BLL() { DataTable dtEmp; try { empOperation = new EmployeeOperation(); dtEmp = empOperation.GetEmployee_DAL(); } catch (SqlException se) { throw se; } catch (Exception ex) { throw ex; } return(dtEmp); }
public DataTable LoadDeparment_BLL() { DataTable dtDept; try { empOperation = new EmployeeOperation(); dtDept = empOperation.LoadDeparment(); } catch (SqlException se) { throw se; } catch (Exception ex) { throw ex; } return(dtDept); }
public List <Employee> PreciceSearchEmployee(int employeeId) { EmployeeOperation employeeOperation = new EmployeeOperation(); bool isExist = employeeOperation.CheckEmployeeExist(employeeId); if (!isExist) { return(null); } else { employeeOperation = new EmployeeOperation(); Employee searchedUser = new Employee(); searchedUser.EmployeeId = employeeId; List <Employee> searchedResult = employeeOperation.GetEmployeeSearchResult(searchedUser); return(searchedResult); } }
public bool UpdateEmployee(Employee employeeToUpate) { Employee employeeItem = new Employee(); employeeItem = EmployeeOperation.Clone <Employee>(employeeToUpate); if (employeeItem.Address == null) { employeeItem.Address = string.Empty; } bool result = new EmployeeOperation().UpdateEmployee(employeeToUpate); if (result) { return(true); } else { return(false); } }
public bool Login(int employeeId) { EmployeeEntity employeeEntity = new EmployeeEntity(); try { List <Employee> searchedEmployeeList = employeeEntity.PreciceSearchEmployee(employeeId); if (searchedEmployeeList == null || searchedEmployeeList.Count != 1) { return(false); } else { CurrentUser = EmployeeOperation.Clone <Employee>(searchedEmployeeList[0]); return(true); } } catch (Exception ex) { throw ex; } }
public bool CreateEmployee(Employee employeeToCreate) { Employee employeeItem = new Employee(); employeeItem = EmployeeOperation.Clone <Employee>(employeeToCreate); employeeItem.FirstName = new CommonEntity().CaptializedName(employeeItem.FirstName); employeeItem.LastName = new CommonEntity().CaptializedName(employeeItem.LastName); if (employeeItem.Address == null) { employeeItem.Address = string.Empty; } bool result = new EmployeeOperation().CreateEmployee(employeeItem); if (result) { return(true); } else { return(false); } }
public void Get_Employ_Response() { this.repo.GetElements(Constant.FilePath).Returns(new OutputWrapper <EmployeEntity> { OutputObject = new List <EmployeEntity> { new EmployeEntity { EmployeNode = new List <EmployeNode> { new EmployeNode { Key = "Name", Value = "TestUser" } } } } }); var result = new EmployeeOperation(this.repo); var output = result.GetEmployes(Constant.FilePath); Assert.IsNotEmpty(output.Result.OutputObject); }
static void Main(string[] args) { // Console.WriteLine(System.Reflection.Assembly.GetExecutingAssembly().GetName().Name); string s; Console.Write("Enter type: "); s = Console.ReadLine(); object obj; switch (s) { case "ef": EmployeeOperationEf ef = new EmployeeOperationEf(); EmployeeRequestObject req = new EmployeeRequestObject(); string id = "17"; // ef.GetAll(); string Id = "4"; ef.GetAll(); ef.Get(id); EmployeeRequestObject e11 = new EmployeeRequestObject(); e11.Id = 8; ef.Delete(Id); EmployeeModel e = new EmployeeModel(); e.Name = "dyu"; // e.Id = 7; // ef.Edit(e); // ef.AddEmployee(e); break; case "ado": //req.Id = Convert.ToInt32(id); EmployeeOperation e3 = new EmployeeOperation(); // SalaryOperations s =new SalaryOperations(); // SalaryModel s1=new SalaryModel(); // s1.SalaryId = 101; // s1.SalaryPaidAmount = 234567; // s1.EmployeeId = 4; //int n=s.AddSalary(s1); // // s.Edit(s1); // s.Delete("3"); EmployeeModel em = new EmployeeModel(); em.Name = "lalit"; // em.Designation = "Developer"; // e.AddEmployee(em); e3.GetAll(); // e.Get("2"); // // em.Id; //e.Edit(em); // e.Delete("2/*");*/ break; default: Console.WriteLine("no suitable op"); break; } //// EmployeeOperationEf e1=new EmployeeOperationEf(); //EmployeeModel model=new EmployeeModel(); //model.Name = "vijay"; //model.Id = 13; //// model.Doj = DateTime.Parse("11/23/2010"); ////e1.AddEmployee(model); ////e1.Edit(model); //// e1.Delete("16"); ////e1.Get("17"); //e1.GetAll(); Console.ReadLine(); }