- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有两个 double 组。有没有一种方法可以使用 FluentAssertions 通过 .BeApproximately() 技术逐个元素地比较数组?
一个范围值对于整个数组就足够了。
例子:
double[] source = { 10.01, 8.01, 6.01 };
double[] target = { 10.0, 8.0, 6.0 };
// THE FOLLOWING IS NOT IMPLEMENTED
target.Should().BeApproximately(source, 0.01);
是否有替代方法?
最佳答案
通用集合断言有一个重载,它采用一个 Func,您可以在比较期间使用它来应用任何谓词。有了它,您可以执行以下操作:
source.Should().Equal(target, (left, right) => AreEqualApproximately(left, right, 0.01));
您唯一需要做的就是自己创建该方法。
关于c# - 流利的断言 : Compare two numeric collections approximately,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17054636/
我正在尝试将fluentd与elasticsearch连接起来,并且在启动td-agent服务时遇到此错误。 td-agent.log: 无法与Elasticsearch通信,重置连接并重试。连接被拒
所以我有一个案例,布局已经变得更加复杂。有一些常见的东西,比如 @section styleIncludes{ ... } ,然后是其他部分,这些部分定义了每个页面可以选择(但几乎总是)指定的各种内容
我刚刚看到一个巨大的 Java 正则表达式,它让我对一般正则表达式的可维护性有所思考。我相信大多数人——除了一些糟糕的 perl 贩子——都会同意正则表达式很难维护。 我在考虑如何解决这种情况。到目前
我有一个 12 秒长的 audio.mp3 文件video.mp4 的长度为 60 秒。 我需要在视频的第 40 秒插入audio.mp3。 如何使用 Node-Fluent-ffmpeg 做到这一点
我正在使用 NHibernate + Fluent 来处理我的应用程序中的数据库。到目前为止,我一直在使用 SessionSource 来创建我的 ISession 对象。我现在对来自 NHibern
我在 Java 控制台应用程序中使用 Apache HttpClient 4.5(具有流畅的界面)。我注意到,它的默认超时值似乎是无限的,但我必须为我发送的请求使用非无限的超时值。我想对所有请求使用相
这是我的路线: router.get("answers","delete", Int.parameter) { req -> Future in let answerID = try
我有随机“ session 已关闭!” Autofac 和 Fluent nHibernate 的以下配置错误: 全局.asax.cs: builder.Register(x => new NHibe
我是一名优秀的程序员,十分优秀!