使用ShouldBeEquivalentTo并处理不同的名称 [英] Using ShouldBeEquivalentTo and handling different names

查看:153
本文介绍了使用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并处理不同的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆