public void Call_ComprehensiveTest() { CallModel cmodel = new CallModel(); EmployeeModel emodel = new EmployeeModel(); ProblemModel pmodel = new ProblemModel(); Calls call = new Calls(); call.DateOpened = DateTime.Now; //call.DateClosed = null; call.OpenStatus = true; call.EmployeeId = emodel.GetByLastname("Park").Id; call.TechId = emodel.GetByLastname("Burner").Id; call.ProblemId = pmodel.GetByDescription("Hard Drive Failure").Id; call.Notes = "Jimin's drive is shot, Burner to fix it"; int newCallId = cmodel.Add(call); output.WriteLine("New Call Generated - Id = " + newCallId); call = cmodel.GetById(newCallId); byte[] oldtimer = call.Timer; output.WriteLine("New Call Retrieved"); call.Notes += "\n Ordered new drive!"; if (cmodel.Update(call) == UpdateStatus.Ok) { output.WriteLine("Call was updated " + call.Notes); } else { output.WriteLine("Call was not updated!"); } call.Timer = oldtimer; call.Notes = "doesn't matter data is stale now"; if (cmodel.Update(call) == UpdateStatus.Stale) { output.WriteLine("Call was not updated due to stale data"); } cmodel = new CallModel(); call = cmodel.GetById(newCallId); if (cmodel.Delete(newCallId) == 1) { output.WriteLine("Call was deleted!"); } else { output.WriteLine("Call was noe deleted"); } Assert.Null(cmodel.GetById(newCallId)); }
public void ComprehensiveModelTestsShouldReturnTrue() { CallModel cmodel = new CallModel(); EmployeeModel emodel = new EmployeeModel(); ProblemModel pmodel = new ProblemModel(); Call call = new Call(); call.DateOpened = DateTime.Now; call.DateClosed = null; call.OpenStatus = true; call.EmployeeId = emodel.GetByLastname("Jarocki").Id; call.TechId = emodel.GetByLastname("Burner").Id; call.ProblemId = pmodel.GetByDescription("Hard Drive Failure").Id; call.Notes = "Kevin's drive is shot, Burner to fix it"; int newCallId = cmodel.Add(call); Console.WriteLine("New Call Generated - Id = " + newCallId); call = cmodel.GetById(newCallId); byte[] oldtimer = call.Timer; Console.WriteLine("New Call Retrieved"); call.Notes += "\n Ordered new RAM!"; if (cmodel.Update(call) == UpdateStatus.Ok) { Console.WriteLine("Call was updated " + call.Notes); } else { Console.WriteLine("Call was not updated!"); } call.Timer = oldtimer; if (cmodel.Update(call) == UpdateStatus.Stale) { Console.WriteLine("Call was not updated due to stale data"); } cmodel = new CallModel(); call = cmodel.GetById(newCallId); if (cmodel.Delete(newCallId) == 1) { Console.WriteLine("call was deleted!"); } else { Console.WriteLine("call was not deleted"); } Assert.IsNull(cmodel.GetById(newCallId)); }
public void EmployeeModelUpdateTwiceShouldReturnStaleStatus() { // EmployeeModel model = new EmployeeModel(); // Employee updateEmployee1 = model.getByLastName("Span"); // Employee updateEmployee2 = model.getByLastName("Span"); // updateEmployee1.PhoneNo = "(555)555-6666"; // if (model.Update(updateEmployee1) == UpdateStatus.Ok) // { // updateEmployee2.PhoneNo = "(555)555-7777"; // Assert.IsTrue(model.Update(updateEmployee2) == UpdateStatus.Stale); // } // else // Assert.Fail(); //} EmployeeModel model1 = new EmployeeModel(); EmployeeModel model2 = new EmployeeModel(); Employee updateEmployee1 = model1.GetByLastname("Span"); Employee updateEmployee2 = model2.GetByLastname("Span"); updateEmployee1.PhoneNo = "(555)555-6556"; if (model1.Update(updateEmployee1) == UpdateStatus.Ok) { updateEmployee2.PhoneNo = "(555)555-7777"; Assert.IsTrue(model2.Update(updateEmployee2) == UpdateStatus.Stale); } else { Assert.Fail(); } }
//Find employee using Lastname Property public void GetByLastname() { try { Employee emp = _model.GetByLastname(Lastname); if (emp == null) { this.Lastname = "not found"; return; } Title = emp.Title; Firstname = emp.FirstName; Lastname = emp.LastName; Phoneno = emp.PhoneNo; Email = emp.Email; Id = emp.Id; DepartmentId = emp.DepartmentId; if (emp.StaffPicture != null) { StaffPicture64 = Convert.ToBase64String(emp.StaffPicture); } Timer = Convert.ToBase64String(emp.Timer); } catch (Exception ex) { this.Lastname = "not found"; Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message); throw ex; } }
public void GetByLastname() { try { Employees emp = _model.GetByLastname(Lastname); this.Title = emp.Title; this.Firstname = emp.FirstName; this.Lastname = emp.LastName; this.Phoneno = emp.PhoneNo; this.Email = emp.Email; this.Id = emp.Id; this.DepartmentId = emp.DepartmentId; this.IsTech = emp.IsTech ?? false; if (emp.StaffPicture != null) { this.StaffPicture64 = Convert.ToBase64String(emp.StaffPicture); } Timer = Convert.ToBase64String(emp.Timer); } catch (NullReferenceException nex) { Lastname = "not found"; } catch (Exception ex) { Lastname = "not Found"; Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message); throw ex; } }
public void EmployeeModelDeleteShouldReturnOne() { EmployeeModel model = new EmployeeModel(); Employee deleteEmployee = model.GetByLastname("Nguyen"); int EmployeeDeleted = model.Delete(deleteEmployee.Id); Assert.IsTrue(EmployeeDeleted == 1); }
public void EmployeeModelGetByLastNameShouldReturnEmployee() { EmployeeModel model = new EmployeeModel(); Employee someEmployee = model.GetByLastname("Nguyen"); Employee anotherEmployee = model.GetById(someEmployee.Id); Assert.IsNotNull(anotherEmployee); }
public void EmployeeModelGetbyIdShouldReturnEmployee() { EmployeeModel model = new EmployeeModel(); Employee someEmployee = model.GetByLastname("Employee"); // retrieve Employee we just added Employee anotherEmployee = model.GetById(someEmployee.Id); // this is for the actual test Assert.IsNotNull(anotherEmployee); }
public void EmployeeModelUpdateShouldReturnOkStatus() { EmployeeModel model = new EmployeeModel(); Employee updateEmployee = model.GetByLastname("Nguyen"); updateEmployee.Email = (updateEmployee.Email.IndexOf(".ca") > 0) ? "*****@*****.**" : "*****@*****.**"; UpdateStatus EmployeeUpdated = model.Update(updateEmployee); Assert.IsTrue(EmployeeUpdated == UpdateStatus.Ok); }
public void EmployeeModelUpdateShouldOkStatus() { EmployeeModel model = new EmployeeModel(); Employee updateEmployee = model.GetByLastname("Jarocki"); updateEmployee.Email = (updateEmployee.Email.IndexOf(".ca") > 0) ? "*****@*****.**" : "*****@*****.**"; UpdateStatus EmployeesUpdated = model.Update(updateEmployee); Assert.IsTrue(EmployeesUpdated == UpdateStatus.Ok); }
public void EmployeeModelUpdateShouldReturnOne() { EmployeeModel model = new EmployeeModel(); Employee updateEmployee = model.GetByLastname("Employee"); // retrieve Employee we just added updateEmployee.Email = "ts.xyz.com"; UpdateStatus EmployeesUpdated = model.UpdateForConcurrency(updateEmployee); Assert.IsTrue(EmployeesUpdated == UpdateStatus.Ok); }
public void Employee_Update() { EmployeeModel model = new EmployeeModel(); Employees employeeForUpdate = model.GetByLastname("Goldenberg"); if (employeeForUpdate != null) { string oldPhoneNo = employeeForUpdate.PhoneNo; string newPhoneNo = oldPhoneNo == "519-555-1235" ? "555-155-5555" : "513-555-1234"; employeeForUpdate.PhoneNo = newPhoneNo; } Assert.True(model.Update(employeeForUpdate) == UpdateStatus.Ok); }
public void EmployeeModelUpdateTwiceShouldReturnStaleStatus() { EmployeeModel model1 = new EmployeeModel(); EmployeeModel model2 = new EmployeeModel(); Employee updateEmployee1 = model1.GetByLastname("Nguyen"); // Should already exist Employee updateEmployee2 = model2.GetByLastname("Nguyen"); // Should already exist updateEmployee1.Email = (updateEmployee1.Email.IndexOf(".ca") > 0) ? "*****@*****.**" : "*****@*****.**"; if (model1.Update(updateEmployee1) == UpdateStatus.Ok) { updateEmployee2.Email = (updateEmployee2.Email.IndexOf(".ca") > 0) ? "*****@*****.**" : "*****@*****.**"; Assert.IsTrue(model2.Update(updateEmployee2) == UpdateStatus.Stale); } else { Assert.Fail(); } }
public void EmployeeModelUpdateTwiceShouldReturnStaleStatus() { EmployeeModel model1 = new EmployeeModel(); EmployeeModel model2 = new EmployeeModel(); Employee updateStudent1 = model1.GetByLastname("Pin"); Employee updateStudent2 = model2.GetByLastname("Pin"); updateStudent1.Email = (updateStudent1.Email.IndexOf(".ca") > 0) ? "*****@*****.**" : "*****@*****.**"; if (model1.Update(updateStudent1) == UpdateStatus.Ok) { updateStudent2.Email = (updateStudent2.Email.IndexOf(".ca") > 0) ? "*****@*****.**" : "*****@*****.**"; Assert.IsTrue(model2.Update(updateStudent2) == UpdateStatus.Stale); } else { Assert.Fail(); } }
public void Employee_ConcurrencyTest() { EmployeeModel model1 = new EmployeeModel(); EmployeeModel model2 = new EmployeeModel(); Employees employeeForUpdate1 = model1.GetByLastname("goldy"); Employees employeeForUpdate2 = model2.GetByLastname("goldy"); if (employeeForUpdate1 != null) { string oldPhoneNo = employeeForUpdate1.PhoneNo; string newPhoneNo = oldPhoneNo == "529-555-1234" ? "555-355-5555" : "519-555-1234"; employeeForUpdate1.PhoneNo = newPhoneNo; if (model1.Update(employeeForUpdate1) == UpdateStatus.Ok) { // need to change the phone # to something else employeeForUpdate2.PhoneNo = "667-666-6666"; Assert.True(model2.Update(employeeForUpdate2) == UpdateStatus.Stale); } else { Assert.True(false); } } }