5
在我的NUnit/FluentAssertions测试中,我比较从我的系统,使用下面的代码引用一个返回的复杂对象:如何在使用ShouldBeEquivalentTo时排除IEnumerable中所有项目的属性?
response.ShouldBeEquivalentTo(reference, o => o.Excluding(x => x.OrderStatus)
.Excluding(x => x.Id)
.Excluding(x => x.Items[0].Name)
.Excluding(x => x.Items[0].Article)
.Excluding(x => x.ResponseStatus));
然而,这不正是我的本意。我想排除Name
和Article
为每对象在Items
列表中,而不仅仅是0。我如何实现这种情况?
我查看了documentation,并没有找到解决方案。我错过了什么吗?
究竟应该如何在我的例子中使用PropertyPath?我已经尝试PropertyPath ==“Items.Name”和“Order.Items.Name”,但它不起作用。 – kojo 2013-03-14 11:35:00
ctx.PropertyPath.EndsWith(“]。Name”)|| ctx.PropertyPath.EndsWith( “]。第二条”)? – 2013-03-15 05:51:49
工作,谢谢。我想,如果我想匹配集合名称,我应该使用正则表达式。 PropertyPath在各种情况下究竟有多精确? – kojo 2013-03-15 11:29:22