Frage

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.

War es hilfreich?

Lösung

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);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top