代码之家  ›  专栏  ›  技术社区  ›  Neil Barnwell

不能让最新的犀牛模型工作

  •  0
  • Neil Barnwell  · 技术社区  · 15 年前

    我不明白-我看过文档,我看不出这段代码有什么问题:

    var mocks = new MockRepository();
    var repository = mocks.StrictMock<IRecipeRepository>();
    IList<Recipe> recipes = new List<Recipe>();
    recipes.Add(new Recipe { ID = 1, Name = "Fish" });
    recipes.Add(new Recipe { ID = 2, Name = "Chips" });
    
    // This line doesn't compile:
    Expect.Call(() => repository.All()).Return(recipes);
    

    这是Rhino Mocks v3.6,对于它,我只能假设有一些破坏性的更改还没有出现在任何文档中。

    1 回复  |  直到 15 年前
        1
  •  1
  •   Neil Barnwell    15 年前

    没关系-我修过了:

    var mocks = new MockRepository();
    var repository = mocks.StrictMock<IRecipeRepository>();
    IList<Recipe> recipes = new List<Recipe>();
    recipes.Add(new Recipe { ID = 1, Name = "Fish" });
    recipes.Add(new Recipe { ID = 2, Name = "Chips" });
    
    Expect.Call(repository.All()).Return(recipes);
    

    很晚了,我想我看不见树木的树林。:)