Пример #1
0
        public void Test_Validated()
        {
            RangeRule val = new RangeRule();

            val.Min = 1;
            val.Max = 20;

            ValidationResult vr = new ValidationResult(true, null);

            Assert.AreEqual(val.Validate("5", new System.Globalization.CultureInfo("en-us")), vr);
        }
Пример #2
0
        public void Test_Illegal_Characters()
        {
            RangeRule val = new RangeRule();

            val.Min = 1;
            val.Max = 20;

            ValidationResult vr = new ValidationResult(false, "Illegal characters");

            Assert.AreEqual(val.Validate("ugh", new System.Globalization.CultureInfo("en-us")), vr);
        }
Пример #3
0
        public void Test_Out_Of_Range()
        {
            RangeRule val = new RangeRule();

            val.Min = 1;
            val.Max = 20;

            ValidationResult vr = new ValidationResult(false, "Please enter a number in the given range.");

            Assert.AreEqual(val.Validate("50", new System.Globalization.CultureInfo("en-us")), vr);
        }
        private void validateMyself()
        {
            if (Validation.GetHasError(CollectionBoxValue))
            {
                RangeRule rr = new RangeRule();
                ValidationResult vr = rr.Validate(CollectionBoxValue.Text, new CultureInfo("en-US", false));

                PrizeLevelConverter plc = new PrizeLevelConverter();
                if (vr.Equals(new ValidationResult(false, "Illegal characters")))
                {
                    ucplID = ErrorService.Instance.ReportError("005", new List<string>{
                        (string)plc.Convert(plObject.prizeLevel)
                    }, ucplID);
                }
                else if (vr.Equals(new ValidationResult(false, "Please enter a number in the given range.")))
                {
                    ucplID = ErrorService.Instance.ReportError("006", new List<string>{
                        (string)plc.Convert(plObject.prizeLevel),
                        "0",
                        "10"
                    }, ucplID);
                }
                else if(vr.Equals(new ValidationResult(false, "Cannot be nothing")))
                {
                    ucplID = ErrorService.Instance.ReportError("008", new List<string>{
                        (string)plc.Convert(plObject.prizeLevel)
                    },
                    ucplID);
                }
            }
            else
            {
                ErrorService.Instance.ResolveError("005", ucplID);
                ErrorService.Instance.ResolveError("006", ucplID);
                ErrorService.Instance.ResolveError("008", ucplID);
            }
            Shout("Update");
            MainWindowModel.Instance.VerifyDivisions();
            MainWindowModel.Instance.VerifyNumTiles();
        }
        private void validateMyself()
        {
            if (Validation.GetHasError(CollectionBoxValue))
            {
                RangeRule rr = new RangeRule();
                ValidationResult vr = rr.Validate(CollectionBoxValue.Text, new CultureInfo("en-US", false));

                PrizeLevelConverter plc = new PrizeLevelConverter();
                if (vr.Equals(new ValidationResult(false, "Illegal characters")))
                {
                    ucplID = ErrorService.Instance.reportError("005", new List<string>{
                        (string)plc.Convert(plObject.prizeLevel,typeof(string), null, new System.Globalization.CultureInfo("en-us"))
                    }, ucplID);
                }
                else if (vr.Equals(new ValidationResult(false, "Please enter a number in the given range.")))
                {
                    ucplID = ErrorService.Instance.reportError("006", new List<string>{
                        (string)plc.Convert(plObject.prizeLevel,typeof(string), null, new System.Globalization.CultureInfo("en-us")),
                        "0",
                        "20"
                    }, ucplID);
                }
                else if(vr.Equals(new ValidationResult(false, "Cannot be nothing")))
                {
                    ucplID = ErrorService.Instance.reportError("008", new List<string>{
                        (string)plc.Convert(plObject.prizeLevel, typeof(string),null, new System.Globalization.CultureInfo("en-us"))
                    },
                    ucplID);
                }
            }
            else
            {
                ErrorService.Instance.resolveError("005", null, ucplID);
                ErrorService.Instance.resolveError("006", null, ucplID);
                ErrorService.Instance.resolveError("008", null, ucplID);
            }

            shout("Update");
        }