示例#1
0
        protected static void AssertHtmlRulePasses(IHtmlRule htmlRule, string bodyHtml)
        {
            var document = GetDocument(bodyHtml);
            var records  = htmlRule.ValidateHtml(document, GetNamespaceManager(document));

            Assert.That(records.Length, Is.EqualTo(0));
        }
示例#2
0
        protected void ExecuteTest(IHtmlRule rule, string bodyHtml)
        {
            XmlDocument         document         = GetDocument(bodyHtml);
            XmlNamespaceManager namespaceManager = GetNamespaceManager(document);

            _errors = rule.ValidateHtml(document, namespaceManager);
        }
示例#3
0
        protected static void AssertHtmlRuleFails(IHtmlRule htmlRule, string bodyHtml, int lineNumber, int linePosition, string message)
        {
            XmlDocument         document         = GetDocument(bodyHtml);
            XmlNamespaceManager namespaceManager = GetNamespaceManager(document);

            IHtmlRule rule    = htmlRule;
            var       records = rule.ValidateHtml(document, namespaceManager);

            Assert.That(records.Length, Is.EqualTo(1));
            Assert.That(records[0].Message, Is.EqualTo(message));
        }
示例#4
0
        public bool ShouldRuleBeIncludedBasedOnConfiguration(IHtmlRule rule)
        {
            string ruleName = rule.GetType().Name;

            string appSetting = ConfigurationManager.AppSettings["NaakRules"];

            string[] configuredRules = appSetting == null ? new string[0] : appSetting.Split(',');

            bool ruleConfigurationNotSpecified = configuredRules.Length == 0;
            bool includeRule = ruleConfigurationNotSpecified || configuredRules.Any(s => s.Trim() == ruleName);

            return(includeRule);
        }