public void ComprehensiveVMTests() { CallViewModel cvm = new CallViewModel(); EmployeeViewModel evm = new EmployeeViewModel(); ProblemViewModel pvm = new ProblemViewModel(); cvm.DateOpened = DateTime.Now; cvm.DateClosed = null; cvm.OpenStatus = true; evm.Lastname = "Jarocki"; evm.GetByLastname(); cvm.EmployeeId = evm.Id; evm.Lastname = "Burner"; evm.GetByLastname(); cvm.TechId = evm.Id; pvm.Description = "Memory Upgrade"; pvm.GetByDescription(); cvm.ProblemId = pvm.Id; cvm.Notes = "Kevin has bad RAM, Burner to fix it"; cvm.Add(); Console.WriteLine("New Call Generated - Id = " + cvm.Id); int id = cvm.Id; //need id for delete later cvm.GetById(); cvm.Notes += "\n Ordered new RAM!"; if (cvm.Update() == 1) { Console.WriteLine("Call was updated " + cvm.Notes); } else { Console.WriteLine("Call was not updated!"); } cvm.Notes = "Another change to comments that should not work"; if (cvm.Update() == -2) { Console.WriteLine("Call was not updated data was stale"); } cvm = new CallViewModel(); cvm.Id = id; cvm.GetById(); if (cvm.Delete() == 1) { Console.WriteLine("Call was deleted!"); } else { Console.WriteLine("Call was not deleted"); } cvm.GetById(); }
public void ComprehensiveVMTests() { CallViewModel cvm = new CallViewModel(); EmployeeViewModel evm = new EmployeeViewModel(); ProblemViewModel pvm = new ProblemViewModel(); cvm.DateOpened = DateTime.Now; cvm.DateClosed = null; cvm.OpenStatus = true; evm.Lastname = "Pollock"; evm.GetByLastname(); cvm.EmployeeId = evm.Id; evm.Lastname = "Burner"; evm.GetByLastname(); cvm.TechId = evm.Id; pvm.Description = "Memory Upgrade"; pvm.GetByDescription(); cvm.ProblemId = pvm.Id; cvm.Notes = "Chris has bad RAM, Burner to fix it"; cvm.Add(); Console.WriteLine("New Call Generated - Id = " + cvm.Id); int id = cvm.Id; // need Id for delete later cvm.GetById(); cvm.Notes += "\n Ordered new RAM!"; if (cvm.Update() == 1) { Console.WriteLine("Call was updated " + cvm.Notes); } else { Console.WriteLine("Call was NOT updated!"); } cvm.Notes = "Another change to comments that should not work."; if (cvm.Update() == -2) { Console.WriteLine("Call was NOT updated, data was stale."); } cvm = new CallViewModel(); // need to reset because of Concurrency cvm.Id = id; cvm.GetById(); if (cvm.Delete() == 1) { Console.WriteLine("Call was deleted!"); } else { Console.WriteLine("Call was NOT deleted!"); } cvm.GetById(); // should throw expected exception }
public void Call_ComprehensiveVMTest() { CallViewModel cvm = new CallViewModel(); EmployeeViewModel evm = new EmployeeViewModel(); ProblemViewModel pvm = new ProblemViewModel(); cvm.DateOpened = DateTime.Now; cvm.DateClosed = null; cvm.OpenStatus = true; evm.Email = "*****@*****.**"; evm.GetByEmail(); cvm.EmployeeId = evm.Id; evm.Lastname = "*****@*****.**"; evm.GetByEmail(); cvm.EmployeeName = evm.Lastname; cvm.TechId = evm.Id; pvm.Description = "Memory Upgrade"; pvm.GetByDescription(); cvm.ProblemId = pvm.Id; cvm.Notes = "Sonia has bad RAM, Burner to fix it"; cvm.Add(); output.WriteLine("New Call Generated - Id = " + cvm.Id); int id = cvm.Id; cvm.GetById(); cvm.Notes += "\n Ordered new RAM!"; if (cvm.Update() == 1) { output.WriteLine("Call was updated " + cvm.Notes); } else { output.WriteLine("Call was not updated!"); } cvm.Notes = "Another change to comments that should not work"; if (cvm.Update() == -2) { output.WriteLine("Call was not updated data was stale"); } cvm = new CallViewModel();// need to reset because of concureency error cvm.Id = id; cvm.GetById(); if (cvm.Delete() == 1) { output.WriteLine("Call was deleted"); } else { output.WriteLine("Call was not deleted"); } Exception ex = Assert.Throws <NullReferenceException>(() => cvm.GetById()); // should throw expected exception Assert.Equal("Object reference not set to an instance of an object.", ex.Message); }
public void ComprehensiveVMTestsShouldReturnTrue() { CallViewModel cvm = new CallViewModel(); EmployeeViewModel evm = new EmployeeViewModel(); ProblemViewModel pvm = new ProblemViewModel(); cvm.DateOpened = DateTime.Now; cvm.DateClosed = null; cvm.OpenStatus = true; evm.Lastname = "Smartypants"; evm.GetByLastname(); cvm.EmployeeId = evm.Id; evm.Lastname = "Burner"; evm.GetByLastname(); cvm.TechId = evm.Id; pvm.Description = "Memory Upgrade"; pvm.GetByProblemDescription(); cvm.ProblemId = pvm.Id; cvm.Notes = "Bigshot has bad RAM, Burner to fix it"; cvm.Version = 1; cvm.Create(); this.tstCtx.WriteLine("New Call Generated - Id = " + cvm.Id); cvm.GetById(); this.tstCtx.WriteLine("New Call Retrieved"); cvm.Notes = "\n Ordered new RAM!"; if (cvm.Update() == 1) { this.tstCtx.WriteLine("Call was updated " + cvm.Notes); } else { this.tstCtx.WriteLine("Call was not updated"); } if (cvm.Update() == -2) { this.tstCtx.WriteLine("Call was not updated data was stale"); } if (cvm.Delete() == 1) { this.tstCtx.WriteLine("Call was deleted"); } else { this.tstCtx.WriteLine("Call was not deleted"); } cvm.GetById(); // should throw expected exception }
public void Call_ComprehensiveVMTest() { CallViewModel cvm = new CallViewModel(); EmployeeViewModel evm = new EmployeeViewModel(); ProblemViewModel pvm = new ProblemViewModel(); cvm.DateOpened = DateTime.Now; //cvm.DateClosed = null; cvm.OpenStatus = true; evm.Email = "*****@*****.**"; evm.GetByEmail(); cvm.EmployeeId = evm.Id; //evm.Lastname = "Park"; evm.Email = "*****@*****.**"; evm.GetByEmail(); cvm.TechId = evm.Id; pvm.Description = "Memory Upgrade"; pvm.GetByDescription(); cvm.ProblemId = pvm.Id; cvm.Notes = "Jimin has bad RAM, Burner to fix it"; cvm.Add(); output.WriteLine("New Call Generated - Id = " + cvm.Id); int id = cvm.Id; cvm.GetById(); cvm.Notes += "\n Ordered new RAM!!"; if (cvm.Update() == 1) { output.WriteLine("Call was updated " + cvm.Notes); } else { output.WriteLine("Call was not updated!"); } //cvm.Notes = "Another change to comments that should not works"; //if (cvm.Update() == -2) { // output.WriteLine("Call was not updated data was stale"); //} //cvm = new CallViewModel(); //cvm.Id = id; //cvm.GetById(); //if (cvm.Delete() == 1) //{ // output.WriteLine("Call was deleted!"); //} //else { // output.WriteLine("Call was not deleted!"); //} //Exception ex = Assert.Throws<NullReferenceException>(() => cvm.GetById()); //Assert.Equal("Object reference not set to an instance of an object.", ex.Message); }
public IHttpActionResult Get(int id) { try { CallViewModel call = new CallViewModel(); call.Id = id; call.GetById(); return(Ok(call)); } catch (Exception ex) { return(BadRequest("Retrieve failed - " + ex.Message)); } }
public IHttpActionResult Get(string id) { try { CallViewModel call = new CallViewModel(); call.Id = id; call.GetById(); return(Ok(call)); } catch (Exception ex) { return(BadRequest("Retrieve failed - " + "error in GetById()")); } }
public IHttpActionResult GetByDescription(string name) { try { CallViewModel call = new CallViewModel(); call.Notes = name; call.GetById(); return(Ok(call)); } catch (Exception ex) { return(BadRequest("Retrieve failed - Contact Tech Support")); } }
public IHttpActionResult GetCallById(string id) { try { CallViewModel call = new CallViewModel(); call.Id = id; call.GetById(); return(Ok(call)); } catch (Exception ex) { return(BadRequest("Retrieve failed - Contact Tech Support")); } }
public IActionResult GetById(int id) { try { CallViewModel call = new CallViewModel(); call.Id = id; call.GetById(); return(Ok(call)); } catch (Exception ex) { _logger.LogError("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message); return(StatusCode(StatusCodes.Status500InternalServerError)); // something went wrong } }