コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
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);
        }
コード例 #4
0
        public ProblemDAOTests()
        {
            DALUtils util = new DALUtils();

            util.LoadCollections();

            ProblemDAO dao  = new ProblemDAO();
            Problem    prob = dao.GetByProblemDescription("Device Not Plugged In");

            pid = prob.GetIdAsString();
        }
コード例 #5
0
 /*
  *  GetByProblemDescription()
  *  Gets the specific problem based on the "Description" of the Problem
  */
 public void GetByProblemDescription()
 {
     try
     {
         Problem prob = _dao.GetByProblemDescription(Description);
         Id          = prob.GetIdAsString();
         Description = prob.Description;
         Version     = prob.Version;
     }
     catch (Exception ex)
     {
         ViewModelUtils.ErrorRoutine(ex, "ProblemViewModel", "GetByProblemDescription");
     }
 }
コード例 #6
0
        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()));
        }
コード例 #7
0
        public void TestGetByProblemDescriptionShouldReturnProblem()
        {
            ProblemDAO dao = new ProblemDAO();

            Assert.IsInstanceOfType(dao.GetByProblemDescription("Device Not Turned On"), typeof(Problem));
        }