public void ProblemDAOGetAllShouldReturnList() { ProblemDAO dao = new ProblemDAO(); List <Problem> probs = dao.GetAll(); Assert.IsTrue(probs.Count > 0); }
public void TestUpdateShouldReturnOk() { ProblemDAO dao = new ProblemDAO(); Problem prob = dao.GetByProblemDescription("Hard Drive Failure"); prob.Description = "No Ram"; Assert.IsTrue(dao.Update(prob) == UpdateStatus.Ok); }
public void TestCreateShouldReturnNewId() { ProblemDAO dao = new ProblemDAO(); Problem prob = new Problem(); prob.Description = "Testing"; prob.Version = 1; Assert.IsTrue(dao.Create(prob).GetIdAsString().Length == 24); }
public ProblemDAOTests() { DALUtils util = new DALUtils(); util.LoadCollections(); ProblemDAO dao = new ProblemDAO(); Problem prob = dao.GetByProblemDescription("Device Not Plugged In"); pid = prob.GetIdAsString(); }
public void TestDeleteShouldReturnOne() { ProblemDAO dao = new ProblemDAO(); Problem prob = dao.GetByProblemDescription("Testing"); if (prob == null) { TestCreateShouldReturnNewId(); prob = dao.GetByProblemDescription("Testing"); } Assert.IsTrue(dao.Delete(prob.GetIdAsString()) == 1); }
public void TestUpdateShouldReturnStale() { ProblemDAO dao = new ProblemDAO(); Problem prob = dao.GetByProblemDescription("Memory Failure"); Problem prob2 = dao.GetByProblemDescription("Memory Failure"); prob.Description = "Butcher"; prob2.Description = "LOL"; UpdateStatus status = dao.Update(prob); Assert.IsTrue(dao.Update(prob2) == UpdateStatus.Stale); }
public void ProblemDAOUpdateShouldReturnTrue() { ProblemDAO dao = new ProblemDAO(); //simulate user 1 getting an Problem Problem prob = dao.GetByID("563d30b53dd4dd34b4c05cc2"); prob.Description = "Device Not Turned On"; int rowsUpdated = dao.Update(prob); //user 1 makes update Assert.IsTrue(rowsUpdated == 1); }
public void TestDeleteShouldReturnOne() { if (!did_create_test_run) { TestCreateShouldReturnNewId(); } ProblemDAO dao = new ProblemDAO(); Problem p = dao.GetById(id_string); Assert.IsTrue(dao.Delete(p.GetIdAsString()) == 1); } // TestShouldReturnOne
public void TestGetByIdShouldReturnProblem() { if (!did_create_test_run) { TestCreateShouldReturnNewId(); } ProblemDAO dao = new ProblemDAO(); Problem p = dao.GetById(id_string); Assert.IsInstanceOfType(p, typeof(Problem)); Assert.AreEqual(p.Description, description); Assert.AreEqual(p.GetIdAsString(), id_string); }// TestGetByIdShouldReturnProblem
public void ProblemDAOCreateAndDeleteShouldReturnTrue() { bool deleteOk = false; Problem prob = new Problem(); ProblemDAO dao = new ProblemDAO(); prob.Description = "Spilt Mountain Dew Code red all over"; string newid = dao.Create(prob); if (newid.Length == 24) // new id's are a 24 byte hex string { deleteOk = dao.Delete(newid); } Assert.IsTrue(deleteOk); }
public void ProblemDAOUpdateTwiceShouldReturnNegative() { ProblemDAO dao = new ProblemDAO(); //simulate 2 users getting an Problem Problem prob = dao.GetByID("563d30b53dd4dd34b4c05cc2"); Problem prob2 = dao.GetByID("563d30b53dd4dd34b4c05cc2"); prob.Description = "Device Not Turned On"; int rowsUpdated = dao.Update(prob); if (rowsUpdated == 1) { rowsUpdated = dao.Update(prob2); } Assert.IsTrue(rowsUpdated == -2); }
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 TestUpdateShouldReturnOk() { if (!did_create_test_run) { TestCreateShouldReturnNewId(); } ProblemDAO dao = new ProblemDAO(); Problem p = dao.GetById(id_string); p.Description = "Go now, there are other worlds then these"; Assert.IsTrue(dao.Update(p) == UpdateStatus.Ok); p = dao.GetById(id_string); // get a new copy with the proper version # p.Description = description; // now revert back to original description Assert.IsTrue(dao.Update(p) == UpdateStatus.Ok); }// TestUpdateShouldReturOk
public void TestCreateShouldReturnNewId() { if (did_create_test_run) { return; } Problem p = new Problem(); ProblemDAO dao = new ProblemDAO(); p.Description = description; p.Version = 1; Assert.IsTrue(dao.Create(p).GetIdAsString().Length == 24); id_string = p.GetIdAsString(); did_create_test_run = true; }// TestCreateShouldReturnNewId
public void TestGetAllJustCrossFingersAndHopeItWorks() { if (!did_create_run) { TestCreateShouldReturnNewId(); } ProblemDAO dao = new ProblemDAO(); ProblemViewModel vm = new ProblemViewModel(); List <Problem> emp_list = dao.GetAll(); List <ProblemViewModel> vm_list = vm.GetAll(); Assert.IsTrue(emp_list.Count == vm_list.Count); for (int i = 0; i < emp_list.Count; i++) { Assert.IsTrue(emp_list[i].GetIdAsString() == vm_list[i].ProblemId); Assert.IsTrue(emp_list[i].Description == vm_list[i].Description); Assert.IsTrue(emp_list[i].Version == vm_list[i].Version); } }// TestGetAllJustCrossFingersAndHopeItWorks
public void TestUpdateShouldReturnStale() { if (!did_create_test_run) { TestCreateShouldReturnNewId(); } ProblemDAO dao = new ProblemDAO(); Problem p1 = dao.GetById(id_string); Problem p2 = dao.GetById(id_string); p1.Description = "description 1"; p1.Description = "description 1"; UpdateStatus status = dao.Update(p1); Assert.IsTrue(dao.Update(p2) == UpdateStatus.Stale); p1 = dao.GetById(id_string); // get a new copy with the proper version # p1.Description = description; // now revert back to original description Assert.IsTrue(dao.Update(p1) == UpdateStatus.Ok); }// TestUpdateShouldReturnStale
public List <CallViewModel> GetAll() { List <CallViewModel> callViewModelList = new List <CallViewModel>(); try { List <Call> calls = _dao.GetAll(); foreach (var call in calls) { CallViewModel cVM = new CallViewModel(); Employee emp = new EmployeeDAO().GetById(call.GetEmployeeIdAsString()); Problem prob = new ProblemDAO().GetByProblemId(call.GetProblemIdAsString()); Employee techName = new EmployeeDAO().GetById(call.GetTechIdAsString()); cVM.Id = call.GetIdAsString(); cVM.ProblemDescription = prob.Description; cVM.EmployeeName = emp.Lastname; cVM.EmployeeId = call.GetEmployeeIdAsString(); cVM.ProblemId = call.GetProblemIdAsString(); cVM.TechId = call.GetTechIdAsString(); cVM.TechName = techName.Lastname; cVM.DateOpened = call.DateOpened; cVM.DateClosed = call.DateClosed; cVM.OpenStatus = call.OpenStatus; cVM.Notes = call.Notes; cVM.Version = call.Version; callViewModelList.Add(cVM); } } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "CallViewModel", "GetAll"); } return(callViewModelList); }
public void TestGetByProblemDescriptionShouldReturnProblem() { ProblemDAO dao = new ProblemDAO(); Assert.IsInstanceOfType(dao.GetByProblemDescription("Device Not Turned On"), typeof(Problem)); }
public void TestGetByProblemIdShouldReturnProblem() { ProblemDAO dao = new ProblemDAO(); Assert.IsInstanceOfType(dao.GetByProblemId(pid), typeof(Problem)); }
public ProblemViewModel() { _dao = new ProblemDAO(); }