[英]Ignore DataMember in Fluent Assertions.ShouldBeEquivalentTo
I'm using the FluentAssertions library to verify serialization is working as expected using the DataContractSerializer. 我正在使用FluentAssertions库使用DataContractSerializer验证序列化是否按预期工作。
Many of the objects I'm serializing have [IgnoreDataMember]
attributes on some properties. 我正在序列化的许多对象的某些属性都具有
[IgnoreDataMember]
属性。
Is there aa way to instruct fluent assertions to disregard ignored data members when performing a ShouldBeEquivalentTo
assertion? 在执行
ShouldBeEquivalentTo
断言时,是否有一种方法可以指示流畅的断言忽略忽略的数据成员?
You can do something like 你可以做类似的事情
actual.ShouldBeEquivalentTo(expected, options => options.Excluding(info => info.RuntimeType.GetCustomAttributes().Any())); actual.ShouldBeEquivalentTo(期望,options => options.Exclusion(info => info.RuntimeType.GetCustomAttributes()。Any()));
The info
object is of type ISubjectInfo
and provides all kinds of information about the involved properties. info
对象的类型为ISubjectInfo
并提供有关所涉及属性的各种信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.