コード例 #1
0
        public void ProblemDAOGetAllShouldReturnList()
        {
            ProblemDAO     dao   = new ProblemDAO();
            List <Problem> probs = dao.GetAll();

            Assert.IsTrue(probs.Count > 0);
        }
コード例 #2
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);
        }
コード例 #3
0
        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);
        }
コード例 #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
        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);
        }
コード例 #6
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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
    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
コード例 #9
0
    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
コード例 #10
0
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
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()));
        }
コード例 #13
0
    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
コード例 #14
0
    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
コード例 #15
0
    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
コード例 #16
0
    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
コード例 #17
0
        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);
        }
コード例 #18
0
        public void TestGetByProblemDescriptionShouldReturnProblem()
        {
            ProblemDAO dao = new ProblemDAO();

            Assert.IsInstanceOfType(dao.GetByProblemDescription("Device Not Turned On"), typeof(Problem));
        }
コード例 #19
0
        public void TestGetByProblemIdShouldReturnProblem()
        {
            ProblemDAO dao = new ProblemDAO();

            Assert.IsInstanceOfType(dao.GetByProblemId(pid), typeof(Problem));
        }
コード例 #20
0
 public ProblemViewModel()
 {
     _dao = new ProblemDAO();
 }