Beispiel #1
0
        public void CheckMissingTag()
        {
            string htmlSource = @"<B><C> This should be centred and in boldface, but the tags are wrongly nested </B></C>";
            // act
            string misMatchTag = MissingTag.FindMissingTag(htmlSource);

            // assert
            Assert.AreEqual(string.Empty, misMatchTag);
        }
Beispiel #2
0
        /// <summary>
        /// Processes registered events for <see cref="MissingTag"/> whenever an expected <see cref="TagNode"/> is not found.
        /// </summary>
        /// <param name="e">Arguments for this event.</param>
        /// <returns>Status indicating whether this event can be ignored.</returns>
        protected virtual bool OnMissingTag(TagEventArgs e)
        {
            if (MissingTag != null)
            {
                foreach (VerifierEventHandler func in MissingTag.GetInvocationList())
                {
                    TagEventCode code = func(e);
                    switch (code)
                    {
                    case TagEventCode.FAIL:
                        return(false);

                    case TagEventCode.PASS:
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            string htmlText = string.Empty;
            bool   isError  = false;

            while (htmlText == string.Empty)
            {
                Console.WriteLine("Write HTML lines to find Tag Problem! (i.e) The following text<C><B>is centred and in boldface</B></C>");
                htmlText = Console.ReadLine();
            }

            try
            {
                string error = MissingTag.FindMisMatchOrder(htmlText);
                if (error != string.Empty)
                {
                    Console.WriteLine(error);
                    isError = true;
                }

                error = MissingTag.FindMissingTag(htmlText);
                if (error != string.Empty)
                {
                    Console.WriteLine(error);
                    isError = true;
                }

                if (!isError)
                {
                    Console.WriteLine("Correctly tagged paragraph");
                }

                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: {0}", ex.Message);
                Console.ReadKey();
            }
        }