I would like to stub a method with the following signature:

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

I'm using Rhino Mocks, any ideas

Thanks

有帮助吗?

解决方案

This one worked for me :

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"
                           }
                   };);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top