Exemplo n.º 1
0
        public void Validate_ValidValidationValues_ReturnsValidResult(object validationObject)
        {
            // Setup
            var rule = new IntegerNumberValidationRule();

            // Call
            ValidationResult result = rule.Validate(validationObject, CultureInfo.InvariantCulture);

            // Assert
            Assert.That(result, Is.EqualTo(ValidationResult.ValidResult));
        }
Exemplo n.º 2
0
        public void Validate_InvalidValidationValues_ReturnsExpectedValidationResult(object validationObject)
        {
            // Setup
            var rule = new IntegerNumberValidationRule();

            // Call
            ValidationResult result = rule.Validate(validationObject, CultureInfo.InvariantCulture);

            // Assert
            Assert.That(result.IsValid, Is.False);
            Assert.That(result.ErrorContent, Is.EqualTo($"{validationObject} could not be parsed as an integer."));
        }
Exemplo n.º 3
0
        public void Validate_InvalidValidationObjects_ReturnsExpectedValidationResult(object validationObject)
        {
            // Setup
            var rule = new IntegerNumberValidationRule();

            // Call
            ValidationResult result = rule.Validate(validationObject, CultureInfo.InvariantCulture);

            // Assert
            Assert.That(result.IsValid, Is.False);
            Assert.That(result.ErrorContent, Is.EqualTo("value must be a string."));
        }
Exemplo n.º 4
0
        public void GivenRuleWithIsWhitespaceStringValidTrue_WhenValidateWithEmptyOrWhiteSpaceString_ThenValidResultReturned(object validationObject)
        {
            // Given
            var rule = new IntegerNumberValidationRule
            {
                IsWhitespaceStringValid = true
            };

            // When
            ValidationResult result = rule.Validate(validationObject, CultureInfo.InvariantCulture);

            // Then
            Assert.That(result, Is.EqualTo(ValidationResult.ValidResult));
        }
Exemplo n.º 5
0
        public void GivenRuleWithIsWhitespaceStringValidFalse_WhenValidateWithEmptyOrWhiteSpaceString_TheExpectedValidationResult(object validationObject)
        {
            // Given
            var rule = new IntegerNumberValidationRule
            {
                IsWhitespaceStringValid = false
            };

            // When
            ValidationResult result = rule.Validate(validationObject, CultureInfo.InvariantCulture);

            // Then
            Assert.That(result.IsValid, Is.False);
            Assert.That(result.ErrorContent, Is.EqualTo($"{validationObject} could not be parsed as an integer."));
        }