public void DigitsOnlyExpressionWillSucceedWhenOnlyDigitsArePresent()
        {
            var instance = new DigitsOnlyExpressionTest { Text = "1234" };
            var result = this.provider.Validate(instance);

            result.Should().NotBeNull("because we should always get a result");
            result.IsApplicable.Should().BeTrue("because a regular expression attribute applies to a string property");
            result.IsSuccess.Should().BeTrue("because the text contains only digits");
        }
示例#2
0
        public void DigitsOnlyExpressionWillSucceedWhenOnlyDigitsArePresent()
        {
            var instance = new DigitsOnlyExpressionTest {
                Text = "1234"
            };
            var result = this.provider.Validate(instance);

            result.Should().NotBeNull("because we should always get a result");
            result.IsApplicable.Should().BeTrue("because a regular expression attribute applies to a string property");
            result.IsSuccess.Should().BeTrue("because the text contains only digits");
        }
示例#3
0
        public void DigitsOnlyExpressionWillFailWhenNonDigitCharactersArePresent()
        {
            var instance = new DigitsOnlyExpressionTest {
                Text = "a"
            };
            var result = this.provider.Validate(instance);

            result.Should().NotBeNull("because we should always get a result");
            result.IsApplicable.Should().BeTrue("because a regular expression attribute applies to a string property");
            result.IsSuccess.Should().BeFalse("because the text contains non-digit characters");
        }
        public void DigitsOnlyExpressionWillFailWhenNonDigitCharactersArePresent()
        {
            var instance = new DigitsOnlyExpressionTest { Text = "a" };
            var result = this.provider.Validate(instance);

            result.Should().NotBeNull("because we should always get a result");
            result.IsApplicable.Should().BeTrue("because a regular expression attribute applies to a string property");
            result.IsSuccess.Should().BeFalse("because the text contains non-digit characters");
        }