public void IsValid(string culture, string value, double minValue, double maxValue, int minDecimalPlaces, int maxDecimalPlaces, bool expectedValue)
        {
            var origCulture = CultureInfo.CurrentCulture;

            CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo(culture);

            try
            {
                var behavior = new NumericValidationBehavior
                {
                    MinimumValue         = minValue,
                    MaximumValue         = maxValue,
                    MinimumDecimalPlaces = minDecimalPlaces,
                    MaximumDecimalPlaces = maxDecimalPlaces
                };
                var entry = new Entry
                {
                    Text = value
                };
                entry.Behaviors.Add(behavior);
                behavior.ForceValidate();
                Assert.Equal(expectedValue, behavior.IsValid);
            }
            finally
            {
                CultureInfo.CurrentCulture = origCulture;
            }
        }
コード例 #2
0
        public void IsValid(string value, double minValue, double maxValue, int minDecimalPlaces, int maxDecimalPlaces, bool expectedValue)
        {
            var behavior = new NumericValidationBehavior
            {
                MinimumValue         = minValue,
                MaximumValue         = maxValue,
                MinimumDecimalPlaces = minDecimalPlaces,
                MaximumDecimalPlaces = maxDecimalPlaces
            };

            new Entry
            {
                Text      = value,
                Behaviors =
                {
                    behavior
                }
            };
            behavior.ForceValidate();
            Assert.Equal(expectedValue, behavior.IsValid);
        }