public void ComprehensiveDAOTestsShouldReturnTrue() { CallDAO cdao = new CallDAO(); EmployeeDAO edao = new EmployeeDAO(); ProblemDAO pdao = new ProblemDAO(); Call call = new Call(); call.DateOpened = System.DateTime.Now; call.DateClosed = null; call.OpenStatus = true; call.SetEmployeeIdFromString(edao.GetByLastname("Smartypants").GetIdAsString()); call.SetTechIdFromString(edao.GetByLastname("Burner").GetIdAsString()); call.SetProblemIdFromString(pdao.GetByProblemDescription("Memory Upgrade").GetIdAsString()); call.Notes = "Bigshot has bad RAM, burner to fix it"; call.Version = 1; call = cdao.Create(call); this.tstCtx.WriteLine("New Call Generated - Id = " + call.GetIdAsString()); call = cdao.GetById(call.GetIdAsString()); this.tstCtx.WriteLine("New Call Retrieved"); call.Notes = "\n Ordered new RAM!"; if (cdao.Update(call) == UpdateStatus.Ok) { this.tstCtx.WriteLine("Call was updated " + call.Notes); } else { this.tstCtx.WriteLine("Call was not updated!"); } if (cdao.Update(call) == UpdateStatus.Stale) { this.tstCtx.WriteLine("Call not updated due to stale data"); } if (cdao.Delete(call.GetIdAsString()) == 1) { this.tstCtx.WriteLine("Call was deleted!"); } else { this.tstCtx.WriteLine("Call was not deleted"); } Assert.IsNull(cdao.GetById(call.GetIdAsString())); }
public void Create() { try { Call call = new Call(); call.EmployeeId = new ObjectId(EmployeeId); call.ProblemId = new ObjectId(ProblemId); call.TechId = new ObjectId(TechId); call.DateOpened = DateOpened; call.DateClosed = DateClosed; call.OpenStatus = OpenStatus; call.Notes = Notes; Id = _dao.Create(call); } catch (Exception ex) { ErrorRoutine(ex, "CallViewModel", "Create"); } }
public void Create() { try { Call call = new Call(); call.SetTechIdFromString(TechId); call.SetEmployeeIdFromString(EmployeeId); call.SetProblemIdFromString(ProblemId); call.DateClosed = DateClosed; call.DateOpened = DateOpened; call.OpenStatus = OpenStatus; call.Notes = Notes; call.Version = Version; Id = (_dao.Create(call)).GetIdAsString(); } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "CallViewModel", "Create"); } }
public void CallDAOComprehensiveTestsReturnTrue() { CallDAO dao = new CallDAO(); Call call = new Call(); call.DateOpened = DateTime.Now; call.DateClosed = null; call.OpenStatus = true; call.EmployeeId = new MongoDB.Bson.ObjectId("56464e723dd4df30e88b8b8c"); //Bigshot call.TechId = new MongoDB.Bson.ObjectId("56464e723dd4df30e88b8b92"); //Burner call.ProblemId = new MongoDB.Bson.ObjectId("56464e723dd4df30e88b8b99"); //memory call.Notes = "Bigshot has bad RAM, Burner to fix it"; string newId = dao.Create(call); this.testContextInstance.WriteLine("New Call Id == " + newId); call = dao.GetByID(newId); this.testContextInstance.WriteLine("Call retrieved"); call.Notes = call.Notes + "\nOrdered new RAM"; if (dao.Update(call) == 1) { this.testContextInstance.WriteLine("Call was updated"); } else { Trace.WriteLine("Call was not updated"); } if (dao.Delete(newId)) { this.testContextInstance.WriteLine("Call was deleted "); } else { this.testContextInstance.WriteLine("Call was not deleted "); } call = dao.GetByID(newId); Assert.IsNull(call); }