使用ShouldBeEquivalentTo并处理不同的名称

编程入门 行业动态 更新时间:2024-10-24 10:19:47
本文介绍了使用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并处理不同的名称

本文发布于:2023-11-30 05:28:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1648878.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:名称   ShouldBeEquivalentTo

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!