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)); }
// Find Call using Id property public void GetById() { try { // Create a new Call object and add the properties // from the object that has called the Add() function Call call = _model.GetById(Id); EmployeeId = call.EmployeeId; ProblemId = call.ProblemId; TechId = call.TechId; DateOpened = call.DateOpened; OpenStatus = call.OpenStatus; DateClosed = call.DateClosed; Notes = call.Notes; Id = call.Id; Timer = Convert.ToBase64String(call.Timer); } catch (NullReferenceException nex) { Notes = "Not Found"; throw nex; } catch (Exception ex) { Notes = "Not Found"; Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message); throw ex; } }
//Retrieve an instance of call using Id property public void GetById() { try { //Retrieve the call that has the same Id as the view model object this method was called on Call call = _model.GetById(Id); //Set the remaining properties of the view model object EmployeeId = call.EmployeeId; ProblemId = call.ProblemId; TechId = call.TechId; DateOpened = call.DateOpened; DateClosed = call.DateClosed; OpenStatus = call.OpenStatus; Notes = call.Notes; Timer = Convert.ToBase64String(call.Timer); } catch (NullReferenceException nex) { Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + nex.Message); throw nex; } catch (Exception ex) { Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message); throw ex; } }
// select a employee be employee email address public void GetById() { try { Calls c = _model.GetById(Id); Id = c.Id; EmployeeId = c.EmployeeId; ProblemId = c.ProblemId; TechId = c.TechId; //EmployeeName = c.Employee; //TechName = c.Tech; //ProblemDescription = c DateOpened = c.DateOpened; DateClosed = c.DateClosed; OpenStatus = c.OpenStatus; Notes = c.Notes; Timer = Convert.ToBase64String(c.Timer); } catch (NullReferenceException nex) { //Id = "not found"; } catch (Exception ex) { //Id = "not found"; Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message); throw ex; } }
public void GetById() { try { Call call = _model.GetById(Id); Id = call.Id; EmployeeId = call.EmployeeId; ProblemId = call.ProblemId; TechId = call.TechId; DateOpened = call.DateOpened; DateClosed = call.DateClosed; OpenStatus = call.OpenStatus; Notes = call.Notes; Timer = Convert.ToBase64String(call.Timer); } catch (Exception ex) { Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message); throw ex; } }