【问题标题】:Rhino Mocks stub ExpressionsRhino 模拟存根表达式
【发布时间】:2012-12-07 11:38:08
【问题描述】:

我想用以下签名存根方法:

Product[] GetAllActive(Expression<Func<Product, bool>> predicate, bool asNoTracking = true, params Expression<Func<Product, object>>[] navigationProperties);

我正在使用 Rhino Mocks,有什么想法

谢谢

【问题讨论】:

    标签: lambda expression rhino-mocks stub stubbing


    【解决方案1】:

    这个对我有用:

    productService.Stub(
                p =>
                p.GetAllActive(
                    Arg<Expression<Func<Product, bool>>>.Is.Anything, 
                    Arg<bool>.Is.Anything, 
                    Arg<Expression<Func<Product, object>>>.Is.Anything)).Return(new[]
                       {
                           new Product
                               {
                                   Id = 1, 
                                   Name = "Special one", 
                                   ShortDescription = "This is product one"
                               }, 
                           new Product
                               {
                                   Id = 2, 
                                   Name = "Special two", 
                                   ShortDescription = "This is product two"
                               }
                       };);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-25
      • 1970-01-01
      • 2011-01-24
      • 2013-05-11
      • 1970-01-01
      • 2011-01-19
      • 1970-01-01
      • 2011-11-23
      相关资源
      最近更新 更多