1

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.

nvoigt
  • 75,013
  • 26
  • 93
  • 142
Djave
  • 277
  • 1
  • 5
  • 14

1 Answers1

2

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);
Ufuk Hacıoğulları
  • 37,978
  • 12
  • 114
  • 156