- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
可能是一个简单的,但无法让它工作;
我已将方法上的签名一更改为任务
在我的单元测试中,我使用了流畅的断言。
但无法让它工作:
_catalogVehicleMapper
.Invoking(m => m.MapToCatalogVehiclesAsync(searchResult, filtersInfo, request, default(CancellationToken)))
.Should().Throw<ArgumentException>()
.WithMessage("One of passed arguments has null value in mapping path and can not be mapped");
MapToCatalogVehiclesAsync
是异步方法,但我需要等待它,但等待和异步调用似乎并没有做到。有人……?
最佳答案
虽然 Fabio 的回答也是正确的,但你也可以这样做:
_catalogVehicleMapper
.Awaiting(m => m.MapToCatalogVehiclesAsync(searchResult, filtersInfo, request, default(CancellationToken)))
.Should().Throw<ArgumentException>()
.WithMessage("One of passed arguments has null value in mapping path and can not be mapped");
作为旁注,我建议始终在 WithMessage
中使用通配符。参见 this blog post 中的第 10 点.
关于c# - 在 fluentassertion 上调用异步任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51661681/
如果我下载 FluentAssertions 1.7.1(我的所有单元测试当前都是针对它编写的),那么我可以引用该 dll,并且下面的测试将正常工作。 但我尝试通过 NuGet 并使用 FluentA
我一直在使用 FluentAssertions 进行单元测试,并开始研究断言是否正确抛出异常。我知道我可以使用 ExpectedExceptions 方法属性,但如果可能的话,我想学习 FluentA
这段代码工作正常 [Test] public void boo() { var collection = new[] { 1, 2, 3 };
我有这样的单元测试代码: // version3 should be a copy of version2 with some differences version3.Data.ShouldBeEq
FluentAssertions 中检查两个对象不相等的最佳方法是什么,如果类没有实现 Equals 而我想用反射进行逐字段比较?基本上我想要 Should().BeEquivalentTo() 的对
我有一个嵌套的 class和 FluentAssertions可以断言它们。 然后我改变class至 struct并且测试失败。 (如果我将 IEnumerable MyItems { get; se
我尝试使用 FluentAssertions 检查我的单元测试,项目列表中的属性类型属于特定类型。 myObj.Items.OfType().Single() .MyPrope
有没有办法使用 FluentAssertions 做这样的事情 response.Satisfy(r => r.Property1== "something" && r.Propert
我正在将 FluentAssertions 与 NUnit 一起使用,但我意识到 Throw() 方法和其他相关方法并未列出供我使用。我是否必须安装任何其他软件包才能访问此方法? 我使用的是 NuGe
因为我有一些角度,所以我想检查角度模数 360°: double angle = 0; double expectedAngle = 360; angle.Should().B
我想知道如何使用 Fluent Assertions 检查一个对象是否从另一个类继承? 我知道我可以使用 IsAssignableFrom 使用 xUnit 来做到这一点,如下所示: [Fact] p
因为我有一些角度,所以我想检查角度模数 360°: double angle = 0; double expectedAngle = 360; angle.Should().B
从我们的数据库中,我们查询放在 ExpandoObject 类型的动态对象集合中的记录集。实现 IDictionary在田野上。这些是实际值。 从我们的 SpecFlow BDD 测试中,我们得到了一
可能是一个简单的,但无法让它工作; 我已将方法上的签名一更改为任务 在我的单元测试中,我使用了流畅的断言。 但无法让它工作: _catalogVehicleMapper
我有以下规范 BidirectionalGraph Fixture = new BidirectionalGraph(); public void VerticesShouldBeAbleToAsso
我尝试不仅将 FluentAssertions 用作测试断言框架,而且还用于检查运行时契约(如高级 Debug.Assert,我已阅读 this 问题)。期望的行为是: 在 Debug模式下:抛出异常
如何比较具有名称相同但类型不同的属性的对象? public class A { public Guid Id { get; set; } } public class B { publ
我正在尝试使用最新版本的 FluentAssertions (4.0.1) 更新我的 Unittest 项目,但由于 API 的更改,我的测试不再编译。在更新之前,我使用的是 3.4.1 版,以下代码
我有一个包含各种类型的字段/属性等的类: public string SomeStringData; public int? SomeNullableIntegerData; public SomeD
当我遇到一个我预计会失败但实际通过的测试时,我正在为一个实用程序库编写一些单元测试。该问题涉及比较两个 float 变量,而不是比较一个 float? 和一个 float 变量。 我使用的是 NUni
我是一名优秀的程序员,十分优秀!