【发布时间】:2023-03-27 15:04:01
【问题描述】:
我正在尝试使用以下方法测试我的收藏:
var costByFactoryt = dataAccess.GetcostPerFactoryt(null, null);
costByFactoryt.Count().Should().BeGreaterThan(0);
costByFactoryt.Select(x => x.Cost.Should().BeGreaterThan(100));
但问题是,如果我把最后一行代码改成,
costByFactoryt.Select(x => x.Cost.Should().BeGreaterThan(1000));
或
costingByCircuit.Select(x => x.Cost.Should().BeLessThan(100));
它仍然通过,这是错误的。
我要测试的是,所有成本都应该大于 100。
【问题讨论】:
-
不要使用 select,而是遍历集合...
-
将全选改为全部
-
其实这个问题和Fluent Assertions无关
标签: c# .net unit-testing fluent-assertions