コード例 #1
0
        public void It_should_match_country_code_exactly(string pattern, string value, bool expectedResult)
        {
            // Act
            IStructureValidator validator = _sut.CreateValidator(string.Empty, pattern);
            bool result = validator.Validate(value);

            // Assert
            result.Should().Be(expectedResult);
        }
コード例 #2
0
        public void Given_pattern_it_should_decompose_into_tests(string pattern, string value, bool expectedResult)
        {
            // Act
            IStructureValidator validator = _sut.CreateValidator(string.Empty, pattern);
            bool result = validator.Validate(value);

            // Assert
            result.Should().Be(expectedResult);
        }
コード例 #3
0
        /// <inheritdoc />
        public void Validate(ValidationContext context)
        {
            IStructureValidator validator = _structureValidationFactory.CreateValidator(
                context.Country.TwoLetterISORegionName,
                context.Country.Iban.Structure
                );

            if (!validator.Validate(context.Value))
            {
                context.Result = IbanValidationResult.InvalidStructure;
            }
        }
コード例 #4
0
        /// <inheritdoc />
        public ValidationRuleResult Validate(ValidationRuleContext context)
        {
            if (context.Country is null)
            {
                return(new InvalidStructureResult());
            }

            IStructureValidator validator = _structureValidationFactory.CreateValidator(
                context.Country.TwoLetterISORegionName,
                context.Country.Iban.Structure
                );

            return(validator.Validate(context.Value)
                ? ValidationRuleResult.Success
                : new InvalidStructureResult());
        }