Using ShouldBeEquivalentTo and handling different names

自闭症网瘾萝莉.ら 提交于 2019-12-11 03:54:52

问题


I want to make a mapper test that maps a database model to a dto

In the database model there is

class Order
{
    long Id
}

But on the Dto the same field is named

class OrderDto
{
    long OrderId
}

Using ShouldBeEquivalentTo how do I tell FluentAssertions that these fields are the same, but the name is different?


回答1:


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.



来源:https://stackoverflow.com/questions/41699863/using-shouldbeequivalentto-and-handling-different-names

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!