public void Validate_WithTestClass(int value, int minValue, int maxValue, bool expected)
        {
            // Arrange
            var sut = new RangeValidationRule <RangeTestClass>(ERROR_MESSAGE, new RangeTestClass(minValue), new RangeTestClass(maxValue));

            // Act
            var result = sut.Validate(new RangeTestClass(value));

            // Assert
            result.Should().Be(expected);
        }
        public void Validate_WithAllowedNullValue_Valid()
        {
            // Arrange
            var sut = new RangeValidationRule <string>(ERROR_MESSAGE, "0", "100");

            // Act
            var result = sut.Validate(null);

            // Assert
            result.Should().BeTrue();
        }
        public void Validate_WithNullValue_NotValid()
        {
            // Arrange
            var sut = new RangeValidationRule <string>(ERROR_MESSAGE, "0", "100", nullIsValid: false);

            // Act
            var result = sut.Validate(null);

            // Assert
            result.Should().BeFalse();
        }
Ejemplo n.º 4
0
 private bool ValidatePassword()
 {
     if (_viewModel.IsEncryptionEnabled)
     {
         RangeValidationRule rule = new RangeValidationRule(NumericQuestion.Types.IntegerType, null, null);
         rule.RegexRule = new RegexValidationRule("");
         string newValue = Password.Text;
         Password.IsValid = true;
         Password.IsValid = rule.Validate(newValue);
         if (!Password.IsValid)
         {
             Password.ValidationContent = Languages.AppResources.validationRules_LengthEmptyMessage;
             return(false);
         }
         else
         {
             return(true);
         }
     }
     return(true);
 }
Ejemplo n.º 5
0
        private void OnCustomValueChanged(object sender, RoutedEventArgs e)
        {
            if (((ValidationControl)sender).Name == "FontSize")
            {
                int minValue             = 15;
                int maxValue             = 35;
                RangeValidationRule rule = new RangeValidationRule(NumericQuestion.Types.IntegerType, minValue, maxValue);

                string newValue = ((ValidationControl)sender).Text;
                ((ValidationControl)sender).IsValid = true;
                ((ValidationControl)sender).IsValid = rule.Validate(newValue);
                if (((ValidationControl)sender).IsValid)
                {
                    OperationsOnSettings.Instance.FontSize = Convert.ToInt32(newValue);
                    _oldFontSize = OperationsOnSettings.Instance.FontSize;
                    LoadSettingsPageContent();
                }
                else
                {
                    ((ValidationControl)sender).ValidationContent = string.Format(Languages.AppResources.settingsPage_InvalidCustomValue, minValue.ToString(), maxValue.ToString());
                }
            }
        }