Пример #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 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);
        }
Пример #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 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
Пример #5
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);
        }
Пример #6
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
Пример #7
0
        public int Update()
        {
            int probsUpdated = -1;

            try
            {
                byte[]  bytProb = Convert.FromBase64String(Entity64);
                Problem prob    = (Problem)Deserializer(bytProb);
                prob.Description = Description;
                probsUpdated     = _dao.Update(prob);
            }
            catch (Exception ex)
            {
                ErrorRoutine(ex, "ProblemViewModel", "Update");
            }
            return(probsUpdated);
        }
Пример #8
0
        public int Update()
        {
            UpdateStatus opStatus;

            try
            {
                Problem prob = new Problem();
                prob.SetIdFromString(ProblemId);
                prob.Description = Description;
                prob.Version     = Version;
                opStatus         = _dao.Update(prob);
            }
            catch (Exception ex)
            {
                ViewModelUtils.ErrorRoutine(ex, "ProblemViewModel", "Update");
                opStatus = UpdateStatus.Failed;
            }
            return(Convert.ToInt16(opStatus));
        }