Пример #1
0
        public void CanValidateGravatar()
        {
            var results = new ValidationResults();
            var widget = new Gravatar();

            // Confirm errors.
            widget.FullName = "123456789012345678901234567890123456789012345678901234567890";
            widget.Rating = "too_long";

            bool success = widget.Validate(results);
            Assert.IsFalse(success);
            Assert.AreEqual(results.Count, 6);

            // Confirm correct
            widget.Header = "about";
            widget.Zone = "right";
            widget.FullName = "kishore reddy";
            widget.Rating = "r";
            widget.Email = "*****@*****.**";
            widget.Size = 80;

            results.Clear();
            success = widget.Validate(results);
            Assert.IsTrue(success);
            Assert.AreEqual(results.Count, 0);
        }
Пример #2
0
        /// <summary>
        /// This checks all the rules for the table that target points too if target does not point to a table returns does not check anything
        /// </summary>
        public void CheckRule()
        {
            //Clear the list from last time
            ValidationResults.Clear();

            // Make sure the target is not null and it is an StreamPropertiesTable
            if (target != null && target is StreamPropertiesTable)
            {
                ITableAdapter tableAdapter = TableAdapterFactory.CreateTableAdapter(
                    target as StreamPropertiesTable);

                ValidationResult vr;

                if (StreamType.Chemical == (target as StreamPropertiesTable).StreamType)
                {
                    vr = unitsAreConsistant(tableAdapter);

                    if (!vr.IsEmpty)
                    {
                        ValidationResults.Add(vr);
                    }

                    vr = sumOfPartsEqualsTotalQuantity(tableAdapter);

                    if (!vr.IsEmpty)
                    {
                        ValidationResults.Add(vr);
                    }
                }
            }
        }
Пример #3
0
        public void CanValidateBlogRoll()
        {
            var results = new ValidationResults();
            var widget  = new BlogRoll()
            {
                Header = "users", Zone = "left"
            };

            // Confirm errors.
            widget.NumberOfEntries = 0;
            widget.BloggerName     = "";
            widget.Url             = "alkjsdflk";
            widget.Format          = "";
            bool success = widget.Validate(results);

            Assert.IsFalse(success);
            Assert.AreEqual(results.Count, 4);

            results.Clear();
            widget.NumberOfEntries = 20;
            widget.BloggerName     = "kishore";
            widget.Url             = "http://kishore.com/rss";
            widget.Format          = "rss";
            success = widget.Validate(results);
            Assert.IsTrue(success);
            Assert.AreEqual(results.Count, 0);
        }
Пример #4
0
        public void CanValidateGravatar()
        {
            var results = new ValidationResults();
            var widget  = new Gravatar();

            // Confirm errors.
            widget.FullName = "123456789012345678901234567890123456789012345678901234567890";
            widget.Rating   = "too_long";

            bool success = widget.Validate(results);

            Assert.IsFalse(success);
            Assert.AreEqual(results.Count, 6);

            // Confirm correct
            widget.Header   = "about";
            widget.Zone     = "right";
            widget.FullName = "kishore reddy";
            widget.Rating   = "r";
            widget.Email    = "*****@*****.**";
            widget.Size     = 80;

            results.Clear();
            success = widget.Validate(results);
            Assert.IsTrue(success);
            Assert.AreEqual(results.Count, 0);
        }
Пример #5
0
        public void UpdateValidationMessage()
        {
            var newValidationResults = Validate();

            if (ValidationResults.SequenceEqual(newValidationResults))
            {
                return;
            }

            ValidationResults.Clear();
            ValidationResults.AddRange(newValidationResults);
            TriggerEvent(new ValidationChangedEvent(DateTime.Now, Name, ValidationMessages));
        }
Пример #6
0
        public void CanValidateUsers()
        {
            var results = new ValidationResults();
            var widget = new Users(){ Header = "users", Zone = "left" };

            // Confirm errors.
            widget.NumberOfEntries = 0;
            widget.NumberOfEntriesAcross = 0;
            bool success = widget.Validate(results);

            Assert.IsFalse(success);
            Assert.AreEqual(results.Count, 2);

            results.Clear();
            widget.NumberOfEntries = 20;
            widget.NumberOfEntriesAcross = 4;
            success = widget.Validate(results);
            Assert.IsTrue(success);
            Assert.AreEqual(results.Count, 0);
        }
        private void Run()
        {
            ValidationResults.Clear();

            var configuration = ConfigurationHelper.Load(ConfigFilePath);
            var ruleProcessor = new RuleProcessor(ProjectFileLocation, configuration, IsReformatEnabled);

            _isRuleEngineWorking = true;

            Task.Factory.StartNew(() => ruleProcessor.Process(validationResult =>
            {
                if (System.Windows.Application.Current.Dispatcher.CheckAccess())
                {
                    ValidationResults.AddRange(validationResult.Messages.Where(vm => !vm.Processed));
                }
                else
                {
                    System.Windows.Application.Current.Dispatcher.Invoke(() => ValidationResults.AddRange(validationResult.Messages.Where(vm => !vm.Processed)));
                }
            })).ContinueWith(t => _isRuleEngineWorking = false);
        }
Пример #8
0
        public void CheckRule()
        {
            ITableAdapter tableAdapter = TableAdapterFactory.CreateTableAdapter(table);

            ValidationResult vr;

            //Clear the list from last time
            ValidationResults.Clear();

            vr = unitsAreConsistant(tableAdapter);

            if (!vr.IsEmpty)
            {
                ValidationResults.Add(vr);
            }

            vr = sumOfPartsEqualsTotalQuantity(tableAdapter);

            if (!vr.IsEmpty)
            {
                ValidationResults.Add(vr);
            }
        }
Пример #9
0
        public void CanValidateUsers()
        {
            var results = new ValidationResults();
            var widget  = new Users()
            {
                Header = "users", Zone = "left"
            };

            // Confirm errors.
            widget.NumberOfEntries       = 0;
            widget.NumberOfEntriesAcross = 0;
            bool success = widget.Validate(results);

            Assert.IsFalse(success);
            Assert.AreEqual(results.Count, 2);

            results.Clear();
            widget.NumberOfEntries       = 20;
            widget.NumberOfEntriesAcross = 4;
            success = widget.Validate(results);
            Assert.IsTrue(success);
            Assert.AreEqual(results.Count, 0);
        }
Пример #10
0
 public virtual void ClearValidationResults()
 {
     ValidationResults.Clear();
 }
Пример #11
0
        public void CanValidateBlogRoll()
        {
            var results = new ValidationResults();
            var widget = new BlogRoll() { Header = "users", Zone = "left" };

            // Confirm errors.
            widget.NumberOfEntries = 0;
            widget.BloggerName = "";
            widget.Url = "alkjsdflk";
            widget.Format = "";
            bool success = widget.Validate(results);

            Assert.IsFalse(success);
            Assert.AreEqual(results.Count, 4);

            results.Clear();
            widget.NumberOfEntries = 20;
            widget.BloggerName = "kishore";
            widget.Url = "http://kishore.com/rss";
            widget.Format = "rss";
            success = widget.Validate(results);
            Assert.IsTrue(success);
            Assert.AreEqual(results.Count, 0);
        }
Пример #12
0
 public void ClearValidation()
 {
     ValidationResults.Clear();
 }