2012-12-20 137 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" 
          } 
        };);