2012-12-20 55 views
4

我想存根具有以下签名的方法:犀牛嘲笑存根表达式

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

我用犀牛嘲笑,任何想法

感谢

回答

6

对我来说这一次的工作:

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" 
          } 
        };);