Using ShouldBeEquivalentTo and handling different

2019-07-17 19:16发布

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条回答
我只想做你的唯一
2楼-- · 2019-07-17 19:43

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.

查看更多
登录 后发表回答