1

我有这样的断言:

validationResults.Select(result => result.Tag).ToList().Should().Contain(ServiceContractRuleKey.MedicalDeclarationNumberRequired "because a validation error should be added that the MedicalDeclarationNumber is missing.");

我怎样才能断言validationResults不应该包含'ServiceContractRuleKey.MedicalDeclarationNumberRequired'

提前致谢。

4

1 回答 1

2

您可以使用 NotContain 方法:

validationResults.Select(result => result.Tag)
                 .ToList()
                 .Should()
                 .NotContain(ServiceContractRuleKey.MedicalDeclarationNumberRequired);

您还可以将谓词传递给 NotContain 方法并简化代码:

validationResults.Should()
                 .NotContain(item => item.Tag == ServiceContractRuleKey.MedicalDeclarationNumberRequired);
于 2013-07-12T07:53:52.363 回答