gpt4 book ai didi

c# - 创建一个 NUnit 约束,意思是 "{collection} does not contain {item}"

转载 作者:IT王子 更新时间:2023-10-29 04:09:07 28 4
gpt4 key购买 nike

我正在努力断言枚举中缺少特定项目。具体来说,我的测试是这样的:

// Take an item from a queue of scheduled items...
ItemQueue pendingQueue = schedule.PendingItems; // PendingItems is an IEnumerable<int>
int item = pendingQueue.FirstItem;

// ...process the item...
processor.DoSomethingWith(item);

// ...and the schedule must not contain the item anymore:
Assert.That(schedule.PendingItems, Does.Not.Contain(item));

当然,Does.Not.Contain 不是有效的 nUnit 约束。我怎样才能用有效的流利语法表达它?

最佳答案

Assert.That(schedule.PendingItems, Has.No.Member(item))

仅适用于 NUnit 2.4/2.5

关于c# - 创建一个 NUnit 约束,意思是 "{collection} does not contain {item}",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3805835/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com