【发布时间】:2021-07-29 02:22:34
【问题描述】:
我正在使用流利的断言并且我有这个测试:
result.Should().NotBeNull();
result.Link.Should().Equals("https://someinvoiceurl.com");
效果很好,但是当我尝试这个时
result.Should().NotBeNull().Which.Link.Equals("https://someinvoiceurl.com");
我收到了这个错误
'AndConstraint<ObjectAssertions>' does not contain a definition for 'Which' and no accessible extension method 'Which' accepting a first argument of type 'AndConstraint<ObjectAssertions>' could be found (are you missing a using directive or an assembly reference?)
我做错了什么?
【问题讨论】:
-
使用
And而不是Which。前者用于链接。后者是前一个断言改变了被断言对象的类型。