示例#1
0
        private bool RunValidationCheck(Configuration configuration, IConfigurationValidation validator, string name, ref int row, IConfigurationErrorProcesser errorProcesser)
        {
            bool isValid = true;

            try
            {
                validator.Validate(configuration, ConfigurationTrace.Start(configuration), errorProcesser);
            }
            catch (Exception error)
            {
                var message = string.Format(System.Globalization.CultureInfo.CurrentCulture, "Internal validation failed for {0}: {1}",
                                            name,
                                            error.Message);
                HtmlAttribute rowClass = new HtmlAttribute("class", (row % 2) == 1 ? "even" : "odd");
                myBodyEl.AppendChild(
                    GenerateElement("div",
                                    rowClass,
                                    GenerateElement("div",
                                                    new HtmlAttribute("class", "error"),
                                                    message)));
                LogMessage(message);
                isValid = false;
                row++;
            }
            return(isValid);
        }
        public void ValidateThrowsErrorsWithoutUrl()
        {
            var processor = this.mocks.Create <IConfigurationErrorProcesser>(MockBehavior.Strict).Object;
            var condition = new UrlPingsTaskCondition();

            Mock.Get(processor).Setup(_processor => _processor.ProcessError("URL cannot be empty")).Verifiable();

            condition.Validate(null, ConfigurationTrace.Start(this), processor);

            this.mocks.VerifyAll();
        }
        public void ValidateThrowsErrorsWithoutUrl()
        {
            var processor = this.mocks.StrictMock <IConfigurationErrorProcesser>();
            var condition = new UrlPingsTaskCondition();

            Expect.Call(() => processor.ProcessError("URL cannot be empty"));

            this.mocks.ReplayAll();
            condition.Validate(null, ConfigurationTrace.Start(this), processor);

            this.mocks.VerifyAll();
        }
        public void ValidatePassesWithUrl()
        {
            var processor = this.mocks.Create <IConfigurationErrorProcesser>(MockBehavior.Strict).Object;
            var condition = new UrlPingsTaskCondition
            {
                Url = "http://somewhere"
            };

            condition.Validate(null, ConfigurationTrace.Start(this), processor);

            this.mocks.VerifyAll();
        }
        public void ValidatePassesWithUrl()
        {
            var processor = this.mocks.StrictMock <IConfigurationErrorProcesser>();
            var condition = new UrlPingsTaskCondition
            {
                Url = "http://somewhere"
            };

            this.mocks.ReplayAll();
            condition.Validate(null, ConfigurationTrace.Start(this), processor);

            this.mocks.VerifyAll();
        }
示例#6
0
        public void ValidateHandlesValidationTasks()
        {
            var subTask = new MockTask();
            var task    = new TestTask
            {
                Tasks = new ITask[]
                {
                    subTask
                }
            };

            task.Validate(null, ConfigurationTrace.Start(null), null);
            Assert.IsTrue(subTask.IsValided);
        }
示例#7
0
        public void ValidateThrowsErrorsWithoutHeaderKey()
        {
            var processor = this.mocks.Create <IConfigurationErrorProcesser>(MockBehavior.Strict).Object;
            var condition = new UrlHeaderValueTaskCondition
            {
                Url = "http://somewhere"
            };

            Mock.Get(processor).Setup(_processor => _processor.ProcessError("Header Key cannot be empty")).Verifiable();

            condition.Validate(null, ConfigurationTrace.Start(this), processor);

            this.mocks.VerifyAll();
        }
示例#8
0
        public void ValidatePassesForTasksSection()
        {
            var task    = new ParallelTask();
            var project = new Project
            {
                Tasks = new ITask[]
                {
                    task
                }
            };
            var errorProcessor = mocks.Create <IConfigurationErrorProcesser>(MockBehavior.Strict).Object;

            task.Validate(null, ConfigurationTrace.Start(project), errorProcessor);
            mocks.VerifyAll();
        }
        public void ValidateThrowsErrorsWithoutHeaderKey()
        {
            var processor = this.mocks.StrictMock <IConfigurationErrorProcesser>();
            var condition = new UrlHeaderValueTaskCondition
            {
                Url = "http://somewhere"
            };

            Expect.Call(() => processor.ProcessError("Header Key cannot be empty"));

            this.mocks.ReplayAll();
            condition.Validate(null, ConfigurationTrace.Start(this), processor);

            this.mocks.VerifyAll();
        }
示例#10
0
        public void ValidateValidatesElseTasks()
        {
            var wasValidated = false;
            var taskMock     = new MockTask()
            {
                ValidateAction = (c, t, ep) => wasValidated = true
            };
            var task = new ConditionalTask
            {
                ElseTasks = new[] { taskMock }
            };

            task.Validate(null, ConfigurationTrace.Start(this), null);
            Assert.IsTrue(wasValidated);
        }
示例#11
0
        public void ValidateFailsForPublishersSection()
        {
            var task    = new ParallelTask();
            var project = new Project
            {
                Publishers = new ITask[]
                {
                    task
                }
            };
            var errorProcessor = mocks.Create <IConfigurationErrorProcesser>(MockBehavior.Strict).Object;

            Mock.Get(errorProcessor).Setup(_errorProcessor => _errorProcessor.ProcessWarning(It.IsAny <string>())).Verifiable();

            task.Validate(null, ConfigurationTrace.Start(project), errorProcessor);
            mocks.VerifyAll();
        }
示例#12
0
        public void ValidateCallsChildrenValidation()
        {
            var processor      = this.mocks.Create <IConfigurationErrorProcesser>(MockBehavior.Strict).Object;
            var validateCalled = false;
            var childCondition = new MockCondition
            {
                ValidateAction = (c, t, ep) => validateCalled = true
            };

            var condition = new OrTaskCondition
            {
                Conditions = new[] { childCondition }
            };

            condition.Validate(null, ConfigurationTrace.Start(this), processor);

            this.mocks.VerifyAll();
            Assert.IsTrue(validateCalled);
        }
示例#13
0
        public void ValidateFailsForPublishersSection()
        {
            var task    = new ParallelTask();
            var project = new Project
            {
                Publishers = new ITask[]
                {
                    task
                }
            };
            var errorProcessor = mocks.StrictMock <IConfigurationErrorProcesser>();

            Expect.Call(() =>
            {
                errorProcessor.ProcessWarning(string.Empty);
            }).IgnoreArguments();
            mocks.ReplayAll();

            task.Validate(null, ConfigurationTrace.Start(project), errorProcessor);
            mocks.VerifyAll();
        }