Example #1
0
        public void TestUpdateShouldReturnStale()
        {
            DepartmentDAO dao  = new DepartmentDAO();
            Department    dep  = dao.GetByDepartmentName("Lab");
            Department    dep2 = dao.GetByDepartmentName("Lab");

            dep.DepartmentName  = "Butcher";
            dep2.DepartmentName = "LOL";
            UpdateStatus status = dao.Update(dep);

            Assert.IsTrue(dao.Update(dep2) == UpdateStatus.Stale);
        }
Example #2
0
    public void TestUpdateShouldReturnOk()
    {
        DepartmentDAO dao  = new DepartmentDAO();
        Department    dep  = dao.GetById(id_string);
        string        name = dep.DepartmentName;

        dep.DepartmentName = "another name";
        Assert.IsTrue(dao.Update(dep) == UpdateStatus.Ok);

        // now revert back to original name!
        dep = dao.GetById(id_string);
        dep.DepartmentName = name;
        Assert.IsTrue(dao.Update(dep) == UpdateStatus.Ok);
    }// TestUpdateShouldReturOk
Example #3
0
        public void DepartmentDAOUpdateTwiceShouldReturnNegative()
        {
            DepartmentDAO dao = new DepartmentDAO();
            //simulate 2 users getting an employee
            Department dep  = dao.GetByID("564107b33dd4ed255425f4c5"); //administrations' id
            Department dep2 = dao.GetByID("564107b33dd4ed255425f4c5"); //administrations' id

            dep.DepartmentName = "Administration";
            int rowsUpdated = dao.Update(dep);

            if (rowsUpdated == 1)
            {
                rowsUpdated = dao.Update(dep2);
            }
            Assert.IsTrue(rowsUpdated == -2);
        }
Example #4
0
        public void TestUpdateShouldReturnOk()
        {
            DepartmentDAO dao = new DepartmentDAO();
            Department    dep = dao.GetByDepartmentName("Maintenance");

            dep.DepartmentName = "Butcher";
            Assert.IsTrue(dao.Update(dep) == UpdateStatus.Ok);
        }
Example #5
0
    public void TestUpdateShouldReturnStale()
    {
        DepartmentDAO dao  = new DepartmentDAO();
        Department    dep1 = dao.GetById(id_string);
        Department    dep2 = dao.GetById(id_string);

        string name = dep1.DepartmentName;

        dep1.DepartmentName = "Test Department";
        dep2.DepartmentName = "name 2";
        UpdateStatus status = dao.Update(dep1);

        Assert.IsTrue(dao.Update(dep2) == UpdateStatus.Stale);

        Department dep = dao.GetById(id_string); // get a new copy of the document with the proper version #

        dep.DepartmentName = name;               // now revert back to original name
        Assert.IsTrue(dao.Update(dep) == UpdateStatus.Ok);
    }// TestUpdateShouldReturnStale
Example #6
0
        public void DepartmentDAOUpdateShouldReturnTrue()
        {
            DepartmentDAO dao = new DepartmentDAO();
            //simulate user 1 getting an employee
            Department dep = dao.GetByID("564107b33dd4ed255425f4c5"); //administrations' id

            dep.DepartmentName = "Administration";
            int rowsUpdated = dao.Update(dep);

            //user 1 makes update
            Assert.IsTrue(rowsUpdated == 1);
        }
        public void Update(int ID, string Name, string Address)
        {
            Department dep = new Department()
            {
                ID      = ID,
                Name    = Name,
                Address = Address
            };
            DepartmentDAO dao = new DepartmentDAO();

            dao.Update(dep);
        }
Example #8
0
        public int Update()
        {
            int updateOk = -1;

            try
            {
                byte[]     bytDep = Convert.FromBase64String(Entity64);
                Department dep    = (Department)Deserializer(bytDep);
                dep.DepartmentName = DepartmentName;
                updateOk           = _dao.Update(dep);
            }
            catch (Exception ex)
            {
                ErrorRoutine(ex, "DepartmentViewModel", "Update");
            }
            return(updateOk);
        }
Example #9
0
        public int Update()
        {
            UpdateStatus opStatus = UpdateStatus.Failed;

            try
            {
                Department dept = new Department();
                dept.SetIdFromString(Id);
                dept.Version        = Version;
                dept.DepartmentName = DepartmentName;

                opStatus = _dao.Update(dept);
            }
            catch (Exception ex)
            {
                ViewModelUtils.ErrorRoutine(ex, "DepartmentViewModel", "Update");
            }

            return(Convert.ToInt16(opStatus));//Web layer won't know about enum
        }
        public int Update()
        {
            UpdateStatus opStatus;

            try
            {
                Department dept = new Department();
                dept.SetIdFromString(Id);
                dept.DepartmentName = DepartmentName;
                dept.Version        = Version;
                ManagerId           = dept.GetManagerIdAsString();
                opStatus            = _dao.Update(dept);
            }
            catch (Exception ex)
            {
                ViewModelUtils.ErrorRoutine(ex, "DepartmentViewModel", "Update");
                opStatus = UpdateStatus.Failed;
            }
            return(Convert.ToInt16(opStatus));
        }