public void InitTestData() { _employeeAddandCreateClient = new EmployeeAddandCreateClient("WSHttpBinding_IEmployeeAddandCreate"); _employeeRetrieveClient = new EmployeeRetrieveClient("BasicHttpBinding_IEmployeeRetrieve"); _employee = new Employee(); _employeeList = new List <Employee>(); }
public void AddAndRetrieveEmployeeDetails() { using (var createClient = new EmployeeCreateClient("BasicHttpBinding_IEmployeeCreate")) using (var retrieveClient = new EmployeeRetrieveClient("WSHttpBinding_IEmployeeRetrieve")) { var emp = createClient.CreateEmployee(1, "saif", "Hello.."); createClient.AddEmployee(emp); var empDetails = retrieveClient.GetById(1); Assert.AreEqual(1, empDetails.EmployeeID); Assert.AreEqual("saif", empDetails.EmployeeName); Assert.AreEqual("Hello..", empDetails.Comment); } }
public void GetEmployeeWhenNoEmployeeExits() { using (var retrieveClient = new EmployeeRetrieveClient("WSHttpBinding_IEmployeeRetrieve")) { try { EmployeeManagement[] employee = retrieveClient.GetAllEmployee(); } catch (FaultException <EmployeeServiceFault> fault) { Assert.AreEqual("Employee Does not exits", fault.Detail.FaultMessage); } } }
public void RemoveEmployeeById() { using (var createClient = new EmployeeCreateClient("BasicHttpBinding_IEmployeeCreate")) using (var retrieveClient = new EmployeeRetrieveClient("WSHttpBinding_IEmployeeRetrieve")) { var emp = createClient.CreateEmployee(2, "saifuddin", "Hello..Again.."); createClient.AddEmployee(emp); var empTwo = createClient.CreateEmployee(1, "saif", "Hello.."); createClient.AddEmployee(empTwo); createClient.RemoveEmployee(1); EmployeeManagement[] employee = retrieveClient.GetAllEmployee(); Assert.AreEqual(1, employee.Length); } }
public void RetrieveEmployeeByID() { using (var createClient = new EmployeeCreateClient("BasicHttpBinding_IEmployeeCreate")) using (var retrieveClient = new EmployeeRetrieveClient("WSHttpBinding_IEmployeeRetrieve")) { var emp = createClient.CreateEmployee(2, "saifuddin", "Hello..Again.."); createClient.AddEmployee(emp); var empTwo = createClient.CreateEmployee(1, "saif", "Hello.."); createClient.AddEmployee(empTwo); var result = retrieveClient.GetById(2); Assert.AreEqual(2, result.EmployeeID); Assert.AreEqual("saifuddin", result.EmployeeName); Assert.AreEqual("Hello..Again..", result.Comment); } }
public void CreateEmployeeUsingDataSource() { using (var createClient = new EmployeeCreateClient("BasicHttpBinding_IEmployeeCreate")) using (var retrieveClient = new EmployeeRetrieveClient("WSHttpBinding_IEmployeeRetrieve")) { int empId = Int32.Parse((string)_testcontextinstance.DataRow["EmployeeId"]); string empName = _testcontextinstance.DataRow["EmployeeName"].ToString(); string empComment = _testcontextinstance.DataRow["EmployeeComment"].ToString(); var emp = createClient.CreateEmployee(empId, empName, empComment); createClient.AddEmployee(emp); var empOneDetails = retrieveClient.GetById(empId); Assert.AreEqual(1, empOneDetails.EmployeeID); Assert.AreEqual("saif", empOneDetails.EmployeeName); Assert.AreEqual("Hello", empOneDetails.Comment); } }
public void GetAllEmployee() { using (var createClient = new EmployeeCreateClient("BasicHttpBinding_IEmployeeCreate")) using (var retrieveClient = new EmployeeRetrieveClient("WSHttpBinding_IEmployeeRetrieve")) { var emp = createClient.CreateEmployee(2, "saifuddin", "Hello..Again.."); createClient.AddEmployee(emp); var empTwo = createClient.CreateEmployee(1, "saif", "Hello.."); createClient.AddEmployee(empTwo); var empThree = createClient.CreateEmployee(3, "saifBatliwala", null); createClient.AddEmployee(empThree); var empFour = createClient.CreateEmployee(4, "Batliwala", null); createClient.AddEmployee(empFour); EmployeeManagement[] employee = retrieveClient.GetAllEmployee(); Assert.AreEqual(4, employee.Length); } }
static void Main(string[] args) { String employeeName = ""; String employeeRemarks = ""; int employeeId = 0; DateTime dateTime = DateTime.Now; int choice = 0; var employeeAddandCreateObject = new EmployeeAddandCreateClient("WSHttpBinding_IEmployeeAddandCreate"); var employeeRetrieveObject = new EmployeeRetrieveClient("BasicHttpBinding_IEmployeeRetrieve"); var employee = new Employee(); try{ do { Console.WriteLine("Employee Management System:"); Console.WriteLine("1.Add Employee Details"); Console.WriteLine("2.Add Employee by Remark"); Console.WriteLine("3.Retrieve Employee By Employee Name"); Console.WriteLine("4.Retrieve Employee By Employee Id"); Console.WriteLine("5.Retrieve Employee By Employee Remark"); Console.WriteLine("6.Retrieve All Employees"); Console.WriteLine("7.Exit"); Console.WriteLine("Enter your Choice:"); choice = Convert.ToInt32(Console.ReadLine()); switch (choice) { case 1: Console.WriteLine("Enter Employee Name:"); employeeName = Console.ReadLine(); Console.WriteLine("Enter Employee Id:"); employeeId = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter Remark:"); employeeRemarks = Console.ReadLine(); Console.WriteLine("Enter Date Time"); dateTime = Convert.ToDateTime(Console.ReadLine()); employee.Name = employeeName; employee.Id = employeeId; employee.Date = dateTime; employee.Text = employeeRemarks; List <Employee> empList = new List <Employee>(); empList.AddRange(employeeAddandCreateObject.CreateEmployee(employee)); break; case 2: Console.WriteLine("Enter EmployeeId"); employeeId = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter EmployeeRemark"); employeeRemarks = Console.ReadLine(); Employee empRemark = employeeAddandCreateObject.AddRemarksById(employeeId, employeeRemarks); Console.WriteLine("EmployeeId:" + empRemark.Id); Console.WriteLine("EmployeeRemark:" + empRemark.Text); break; case 3: Console.WriteLine("Enter EmployeeName"); employeeName = Console.ReadLine(); Employee empName = employeeRetrieveObject.SearchByName(employeeName); Console.WriteLine("EmployeeId:" + empName.Id); Console.WriteLine("EmployeeRemark:" + empName.Text); Console.WriteLine("EmployeeName:" + empName.Name); Console.WriteLine("EmployeeDate:" + empName.Date); break; case 4: Console.WriteLine("Enter EmployeeId"); employeeId = Convert.ToInt32(Console.ReadLine()); Employee empId = employeeRetrieveObject.SearchById(employeeId); Console.WriteLine("EmployeeId:" + empId.Id); Console.WriteLine("EmployeeRemark:" + empId.Text); Console.WriteLine("EmployeeName:" + empId.Name); Console.WriteLine("EmployeeDate:" + empId.Date); break; case 5: employeeRemarks = Console.ReadLine(); List <Employee> empRemarkList = new List <Employee>(); empRemarkList.AddRange(employeeRetrieveObject.SearchByRemark(employeeRemarks)); foreach (Employee emp in empRemarkList) { Console.WriteLine("EmployeeId:" + emp.Id); Console.WriteLine("EmployeeRemark:" + emp.Text); Console.WriteLine("EmployeeName:" + emp.Name); Console.WriteLine("EmployeeDate:" + emp.Date); } break; case 6: List <Employee> empAllEmployeeList = new List <Employee>(); empAllEmployeeList.AddRange(employeeRetrieveObject.GetAllEmployees()); foreach (Employee emp in empAllEmployeeList) { Console.WriteLine("EmployeeId:" + emp.Id); Console.WriteLine("EmployeeRemark:" + emp.Text); Console.WriteLine("EmployeeName:" + emp.Name); Console.WriteLine("EmployeeDate:" + emp.Date); } break; case 7: break; default: Console.WriteLine("Invalid Choice"); break; } } while (choice != 7); } catch (FaultException <FaultExceptionContract> ex) { string msg = "StatusCode: " + ex.Detail.StatusCode; msg += "\nMessage: " + ex.Detail.Message; Console.WriteLine(msg); } Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("Client is Running.........."); using (EmployeeCreateClient _clientcreate = new EmployeeCreateClient("BasicHttpBinding_IEmployeeCreate")) using (EmployeeRetrieveClient _clientretrive = new EmployeeRetrieveClient("WSHttpBinding_IEmployeeRetrieve")) { int choice; string ch = " "; do { Console.WriteLine("---------------------------------------"); Console.WriteLine("Employee Management Service"); Console.WriteLine("---------------------------------------"); Console.WriteLine("1. Create & Add New Employee"); Console.WriteLine("2. Modify Comment of Employee"); Console.WriteLine("3. Get Employee Details by Name"); Console.WriteLine("4. Get Employee Details by ID"); Console.WriteLine("5. Get List of All Employee"); Console.WriteLine("6. Remove Employee From List"); Console.WriteLine("---------------------------------------"); choice = Int32.Parse(Console.ReadLine()); switch (choice) { case 1: try { Console.WriteLine("Enter Employee ID : "); var empId = int.Parse(Console.ReadLine()); Console.WriteLine("Enter Employee Name : "); var empName = Console.ReadLine(); Console.WriteLine("Enter Employee comment : "); var comment = Console.ReadLine(); var emp = _clientcreate.CreateEmployee(empId, empName, comment); _clientcreate.AddEmployee(emp); Console.WriteLine("Employee Details Added Successfully..."); } catch (FaultException <EmployeeServiceFault> ex) { Console.WriteLine("FaultId::" + ex.Detail.FaultId); Console.WriteLine("FaultMessage::" + ex.Detail.FaultMessage + Environment.NewLine); Console.WriteLine("FaultDetails::" + Environment.NewLine + ex.Detail.FaultDetail); } break; case 2: try { Console.WriteLine("Enter Employee Id to Add/Modify Comment : "); var id = int.Parse(Console.ReadLine()); Console.WriteLine("Enter Comment "); var modifyComment = Console.ReadLine(); _clientcreate.ModifyComment(id, modifyComment); Console.WriteLine("Comment modified/Added Successfully.."); } catch (FaultException <EmployeeServiceFault> ex) { Console.WriteLine("FaultId::" + ex.Detail.FaultId); Console.WriteLine("FaultMessage::" + ex.Detail.FaultMessage + Environment.NewLine); Console.WriteLine("FaultDetails::" + Environment.NewLine + ex.Detail.FaultDetail); } break; case 3: try { Console.WriteLine("Enter Name of Employee to Get Employee Details : "); var name = Console.ReadLine(); var getEmp = _clientretrive.GetByName(name); Console.WriteLine(getEmp.EmployeeID + " " + getEmp.EmployeeName + " " + getEmp.Comment + " " + getEmp.TimeSubmitted); Console.WriteLine("Employee Details Found..."); } catch (FaultException <EmployeeServiceFault> ex) { Console.WriteLine("FaultId::" + ex.Detail.FaultId); Console.WriteLine("FaultMessage::" + ex.Detail.FaultMessage + Environment.NewLine); Console.WriteLine("FaultDetails::" + Environment.NewLine + ex.Detail.FaultDetail); } break; case 4: try { Console.WriteLine("Enter Employee Id to Search Employee : "); var searchId = int.Parse(Console.ReadLine()); var getEmp1 = _clientretrive.GetById(searchId); Console.WriteLine(getEmp1.EmployeeID + " " + getEmp1.EmployeeName + " " + getEmp1.Comment + " " + getEmp1.TimeSubmitted); Console.WriteLine("Employee Details Found..."); } catch (FaultException <EmployeeServiceFault> ex) { Console.WriteLine("FaultId::" + ex.Detail.FaultId); Console.WriteLine("FaultMessage::" + ex.Detail.FaultMessage + Environment.NewLine); Console.WriteLine("FaultDetails::" + Environment.NewLine + ex.Detail.FaultDetail); } break; case 5: try { EmployeeManagement[] employee = _clientretrive.GetAllEmployee(); foreach (EmployeeManagement em in employee) { Console.WriteLine(em.EmployeeID + " " + em.EmployeeName + " " + em.Comment + " " + em.TimeSubmitted); } } catch (FaultException <EmployeeServiceFault> ex) { Console.WriteLine("FaultId::" + ex.Detail.FaultId); Console.WriteLine("FaultMessage::" + ex.Detail.FaultMessage + Environment.NewLine); Console.WriteLine("FaultDetails::" + Environment.NewLine + ex.Detail.FaultDetail); } break; case 6: try { Console.WriteLine("Enter Employee Id to Remove Its Details : "); var removeId = int.Parse(Console.ReadLine()); _clientcreate.RemoveEmployee(removeId); Console.WriteLine("Employee Details Removed Successfully..."); } catch (FaultException <EmployeeServiceFault> ex) { Console.WriteLine("FaultId::" + ex.Detail.FaultId); Console.WriteLine("FaultMessage::" + ex.Detail.FaultMessage + Environment.NewLine); Console.WriteLine("FaultDetails::" + Environment.NewLine + ex.Detail.FaultDetail); } break; default: Console.WriteLine("Invalid Choice.."); break; } Console.WriteLine("Do You Want To Continue(y/n) : "); ch = Console.ReadLine(); } while (ch.Equals("Y") || ch.Equals("y")); } }