Reputation: 287
I have a assertion like this:
validationResults.Select(result => result.Tag).ToList().Should().Contain(ServiceContractRuleKey.MedicalDeclarationNumberRequired "because a validation error should be added that the MedicalDeclarationNumber is missing.");
How can i make it to assert that the validationResults should not contain the 'ServiceContractRuleKey.MedicalDeclarationNumberRequired'
?
Thanks in advance.
Upvotes: 1
Views: 426
Reputation: 38468
You can use NotContain method:
validationResults.Select(result => result.Tag)
.ToList()
.Should()
.NotContain(ServiceContractRuleKey.MedicalDeclarationNumberRequired);
You can also pass a predicate to NotContain method and simplify your code:
validationResults.Should()
.NotContain(item => item.Tag == ServiceContractRuleKey.MedicalDeclarationNumberRequired);
Upvotes: 2