Lambda Rhino模仿存根表达式
我想用以下签名来存根一个方法:Lambda Rhino模仿存根表达式,lambda,expression,rhino-mocks,stub,stubbing,Lambda,Expression,Rhino Mocks,Stub,Stubbing,我想用以下签名来存根一个方法: Product[] GetAllActive(Expression<Func<Product, bool>> predicate, bool asNoTracking = true, params Expression<Func<Product, object>>[] navigationProperties); Product[]getAllActivity(表达式谓词,bool asNoTracking=tru
Product[] GetAllActive(Expression<Func<Product, bool>> predicate, bool asNoTracking = true, params Expression<Func<Product, object>>[] navigationProperties);
Product[]getAllActivity(表达式谓词,bool asNoTracking=true,参数表达式[]导航属性);
我在用犀牛模型,有什么想法吗
谢谢这个对我很有用:
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"
}
};);
productService.Stub(
p=>
p、 GetAllActive(
Arg.Is.任何东西,
Arg.Is.任何东西,
Arg.Is.Anything().Return(新[]
{
新产品
{
Id=1,
Name=“特殊一款”,
ShortDescription=“这是产品一”
},
新产品
{
Id=2,
Name=“特殊二号”,
ShortDescription=“这是产品二”
}
};);