Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
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("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));
        }
Ejemplo n.º 3
0
        public int Delete()
        {
            int callsDeleted = -1;

            try
            {
                callsDeleted = _model.Delete(Id);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message);
                throw ex;
            }
            return(callsDeleted);
        }
Ejemplo n.º 4
0
        // Delete a Call
        public int Delete()
        {
            // Sets the number of Employees deleted
            // None of been deleted until we try and actually remove them
            // from the database
            int CallsDeleted = -1;

            try
            {
                // Trys to delete the Call from the database
                // The Id is past from the EmployeeController from the object
                // that called the inital Delete function
                CallsDeleted = _model.Delete(Id);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Problem in " + GetType().Name + " " +
                                  MethodBase.GetCurrentMethod().Name + " " + ex.Message);
                throw ex;
            }

            // Returns the number of employees deleted
            return(CallsDeleted);
        }