Ejemplo n.º 1
0
        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("Tessier").Id;
            call.TechId     = emodel.GetByLastName("Burner").Id;
            call.ProblemId  = pmodel.GetByDescription("Hard Drive Failure").Id;
            call.Notes      = "Sabrina'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 getByLastName()
 {
     try
     {
         Employee emp = _model.GetByLastName(Lastname);
         Title        = emp.Title;
         Firstname    = emp.FirstName;
         Lastname     = emp.LastName;
         Email        = emp.Email;
         Phoneno      = emp.PhoneNo;
         ID           = emp.Id;
         DepartmentID = emp.DepartmentId;
         if (emp.StaffPicture != null)
         {
             staffPicture64 = Convert.ToBase64String(emp.StaffPicture);
         }
         Timer = Convert.ToBase64String(emp.Timer);
     }
     catch (Exception ex)
     {
         Lastname = "Not found";
         Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message);
         throw ex;
     }
 }
 public void EmployeeModelGetbyIdShouldReturnEmployee()
 {
     EmployeeModel model = new EmployeeModel();
     Employee emp = model.GetByLastName("Employee");
     Employee anotherEmp = model.GetById(emp.Id);
     Assert.IsNotNull(anotherEmp);
 }
 public void EmployeeModelDeleteShouldReturnOne()
 {
     EmployeeModel model = new EmployeeModel();
     Employee deleteEmp = model.GetByLastName("Employee");
     int employeesDeleted = model.Delete(deleteEmp.Id);
     Assert.IsTrue(employeesDeleted == 1);
 }
        //find employee using Lastname property by using the EmployeeModel object
        public void GetByLastName()
        {
            try
            {
                Employee emp = _model.GetByLastName(Lastname);
                if (emp == null)
                {
                    this.Lastname = "not found";
                    return;
                }

                //Set the remaining properties of the view model object based on the properties of the employee model object
                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)
            {
                Lastname = "not found";
                Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message);
                throw ex;
            }
        }
 public void EmployeeModelUpdateShouldReturnOkStatus()
 {
     EmployeeModel model = new EmployeeModel();
     Employee updateEmployee = model.GetByLastName("Tessier");
     updateEmployee.Email = (updateEmployee.Email.IndexOf(".ca") > 0) ? "*****@*****.**" : "*****@*****.**";
     UpdateStatus EmployeesUpdated = model.Update(updateEmployee);
     Assert.IsTrue(EmployeesUpdated == UpdateStatus.Ok);
 }
 public void EmployeeModelUpdateTwiceShouldReturnStaleStatus()
 {
     EmployeeModel model1 = new EmployeeModel();
     EmployeeModel model2 = new EmployeeModel();
     Employee updateEmp1 = model1.GetByLastName("Tessier");
     Employee updateEmp2 = model2.GetByLastName("Tessier");
     updateEmp1.Email = (updateEmp1.Email.IndexOf(".ca") > 0) ? "*****@*****.**" : "*****@*****.**";
     if (model1.Update(updateEmp1) == UpdateStatus.Ok)
     {
         updateEmp2.Email = (updateEmp2.Email.IndexOf(".ca") > 0) ? "*****@*****.**" : "*****@*****.**";
         Assert.IsTrue(model2.Update(updateEmp2) == UpdateStatus.Stale);
     }
     else
         Assert.Fail();
 }