FluentAssertion - 向if语句添加断言

Phi*_*una 0 c# nunit unit-testing assertion fluent-assertions

我有以下Fluent Assertion,我想在if语句中添加.我收到一个错误,说我不能隐式地将类型转换为bool.

我试图明确地转换它但我仍然得到一个错误,说不能将类型转换为bool.

actors.Cast.Should().Contain(actor => actor.Name == "Emilia Clark");

检查上述陈述是否属实的最佳方法是什么?

Nko*_*osi 6

检查上述陈述是否属实的最佳方法是什么?

什么都不做.

如果不是这样,测试将失败,因为它会抛出异常.

//... Code before

//Assert
actors.Cast.Should().Contain(actor => actor.Name == "Emilia Clark");

//...if we reach this far it is true. Carry on.

//...other code
Run Code Online (Sandbox Code Playgroud)