Question

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.

Was it helpful?

Solution

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top