本文介绍了使用ShouldBeEquivalentTo并处理不同的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想进行将数据库模型映射到dto的映射器测试
I want to make a mapper test that maps a database model to a dto
在数据库模型中有
class Order { long Id }但是在Dto上,相同的字段被命名为
But on the Dto the same field is named
class OrderDto { long OrderId }使用ShouldBeEquivalent要如何告诉FluentAssertions这些字段相同,但名称不同?
Using ShouldBeEquivalentTo how do I tell FluentAssertions that these fields are the same, but the name is different?
推荐答案它并不是您所要的,但是您可以使用使用时间.尽管您需要做很多事情,但它的语法有点笨拙且冗长.可能是我能想到的最接近的东西.
Its not exactly what you are asking for, but you can override the assertion comparison completely in fluent assertions for a given property with Using When. Its a little clunky and long winded syntax though if you need to do a lot of them. Probably the closest thing I can think of in there.
更多推荐
使用ShouldBeEquivalentTo并处理不同的名称
发布评论