예제 #1
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
예제 #2
0
    public void TestGetByIdShouldReturnDepartment()
    {
        DepartmentDAO dao = new DepartmentDAO();
        Department    dep = dao.GetById(id_string);

        Assert.IsInstanceOfType(dep, typeof(Department));
        Assert.AreEqual(dep.DepartmentName, "Sales");
        Assert.AreEqual(dep.GetIdAsString(), id_string);
    }// TestGetByIdShouldReturnDepartment
예제 #3
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
예제 #4
0
 public void GetById()
 {
     try
     {
         Department dept = _dao.GetById(Id);
         DepartmentName = dept.DepartmentName;
         Version        = dept.Version;
         Id             = dept.GetIdAsString();
     }
     catch (Exception ex)
     {
         Id = "not found";
         ViewModelUtils.ErrorRoutine(ex, "DepartmentViewModel", "GetById");
     }
 }
 public void GetById()
 {
     try
     {
         Department dept = _dao.GetById(Id);
         DepartmentName = dept.DepartmentName;
         Version        = dept.Version;
         ManagerId      = dept.GetManagerIdAsString();
         Id             = dept.GetIdAsString();
     }
     catch (Exception ex)
     {
         ViewModelUtils.ErrorRoutine(ex, "EmployeeViewModel", "GetById");
     }
 }