public void Validate_TypeWithListOfIntegersAreCorrect_Success() { var instance = new TypeWithListOfIntegers { IntegersList = new List <int> { 11, 50, 99, 100, 10 } }; var result = RecursiveValidator.Validate(instance); result.Should().BeOfType <SuccessfulResult>(); }
public void Validate_TypeWithListOfIntegersOverheadsRange_Fails() { var instance = new TypeWithListOfIntegers { IntegersList = new List <int> { 11, 80, 999, 77 } }; var result = RecursiveValidator.Validate(instance); result.Should().BeOfType <FailedResult>() .Which.Code.Should().Be(CoreErrorCodes.ValidationFailed.Code); var errorDetails = ((FailedResult)result).Details.ToArray(); errorDetails.Length.Should().Be(1); errorDetails[0].Source.Should().Be($"{nameof(TypeWithListOfIntegers)}.{nameof(TypeWithListOfIntegers.IntegersList)}.2"); errorDetails[0].CodeInfo.Code.Should().BeEquivalentTo(AnnotationErrorCodes.Range.Code); }