Enumerator 'Update' class 不包含定义,但仅用于单元测试方法,而不是在 DAL 项目内部使用时

Enumerator 'Update' class does not contain a definition, but only for the Unit Testing method and not when it use inside the DAL project

我正在尝试 运行 在我的 DAL layer/project 中对 DAO (EmployeeDAO.cs) 中的更新方法进行单元测试。在 EmployeeDAO.cs class 中,我的更新方法

public UpdateStatus Update(Employee emp)
    {
        UpdateStatus status = UpdateStatus.Failed;
        HelpdeskRepository repo = new HelpdeskRepository(new DbContext());
        try
        {
            DbContext ctx = new DbContext();
            var builder = Builders<Employee>.Filter;
            var filter = Builders<Employee>.Filter.Eq("Id", emp.Id) & Builders<Employee>.Filter.Eq("Version", emp.Version);
            var update = Builders<Employee>.Update
                .Set("DepartmentId", emp.DepartmentId)
                .Set("Email", emp.Email)
                .Set("Firstname", emp.Firstname)
                .Set("Lastname", emp.Lastname)
                .Set("Phoneno", emp.Phoneno)
                .Set("Title", emp.Title)
                .Inc("Version", 1);

            var result = ctx.Employees.UpdateOne(filter, update);
            status = repo.Update(emp.Id.ToString(), filter, update);

            //ask how to get status to work in MatchedCount/Modified count so we don't need DbContext use
            if (result.MatchedCount == 0) //if zero version didn't match
            {
                status = UpdateStatus.Stale;
            }
            else if (result.ModifiedCount == 1)
            {
                status = UpdateStatus.Ok;
            }
            else
            {
                status = UpdateStatus.Failed;
            }
        }
        catch (Exception ex)
        {
            DALUtils.ErrorRoutine(ex, "EmployeeDAO", "UpdateWithRepo");

        }
        return status;
    }

似乎工作正常,编译器未检测到错误。但是,当我尝试在我的 EmployeeDAOTests 中使用此方法对其进行一些单元测试时。cs/UnitTestProject 在同一解决方案中,

[TestMethod]
    public void TestUpdateShouldReturnOK()
    {
        EmployeeDAO dao = new EmployeeDAO();
        Employee emp = dao.GetById(eid);
        emp.Phoneno = "(555)555-9999";
        Assert.IsTrue(dao.Update(emp) == UpdateStatus.OK);
    }

它告诉我

(CS0117)"'UpdateStatus' does not contain a definition for 'OK'"

,在这里可以很明显地看到 OK 的定义似乎对在我的实际 DAO 中使用有效:

public enum UpdateStatus
{


    Ok = 1,
    Failed = -1,
    Stale = -2
};

另一方面,当我按照我定义的 Ok、Failed 和 Stale 顺序进行交易时,它不再导致单元测试错误,但开始导致 DAO 错误!

非常困惑,有人有任何意见吗?

这是一个小的错误:) UpdateStatus.OK 应该是 UpdateStatus.Ok :)