代码之家  ›  专栏  ›  技术社区  ›  Matt Roberts

亚音速3.0测试库“查找”不工作

  •  0
  • Matt Roberts  · 技术社区  · 14 年前

    // 2 Approved, 4 pending, 3 rejected
    var data = new List<Conference>
                   {
                       new Conference {Approved = true, Rejected = false},
                       new Conference {Approved = true, Rejected = false},
                       new Conference {Approved = false, Rejected = false},
                       new Conference {Approved = false, Rejected = false},
                       new Conference {Approved = false, Rejected = false},
                       new Conference {Approved = false, Rejected = false},
                       new Conference {Approved = false, Rejected = true},
                       new Conference {Approved = false, Rejected = true},
                       new Conference {Approved = false, Rejected = true}
                   };
    
    Conference.ResetTestRepo();
    Conference.Setup(data);
    

    然后我的Repo类最终使用Find()执行这一行:

    return Conference.Find(c => c.Approved).ToList(); 
    

    问题是,它总是返回所有记录(9)。我试过不同的寻找标准,但都没有用。

    有人知道问题是什么吗?我已尝试修复tt模板中的相等比较,如下所述: Fixes for problems with SubSonic 3's TestRepository 但那没用。

    2 回复  |  直到 7 年前
        1
  •  1
  •   Matt Roberts    14 年前

    所以从。找到。。。

    return Conference.All().Where(c => c.Approved == true).ToList(); 
    

    解决它。

        2
  •  0
  •   Jürgen Steinblock    14 年前

    应该没什么区别,但你试过:

    return Conference.Find(c => c.Approved == true).ToList(); 
    
    推荐文章