예제 #1
0
        public static void Run()
        {
            Console.Write("Processing files ... ");
            var sw   = Stopwatch.StartNew();
            var a    = XMLConfTest.GenerateFromFile(@"...\xmlconf-20010315.htm");
            var code = a.ToCode();

            File.WriteAllText("xmltest.cs", code);
            sw.Stop();
            Console.WriteLine("done!");
            Console.WriteLine("{0} files have been processed in {1} ms.", a.Tests.Select(m => m.Value).Select(m => m.Count).Sum(), sw.ElapsedMilliseconds);
        }
예제 #2
0
        /// <summary>
        /// Generates the unit tests from the given overview document.
        /// </summary>
        /// <param name="document">The document to inspect.</param>
        public static XMLConfTest GenerateFromHtml(IDocument document)
        {
            var body = document.Body;
            var mode = Mode.None;
            var test = new XMLConfTest();

            for (int i = 0; i < body.ChildNodes.Length; i++)
            {
                var child   = body.ChildNodes[i];
                var element = child as IHtmlAnchorElement;

                if (element != null && element.HasAttribute("name"))
                {
                    switch (element.GetAttribute("name"))
                    {
                    case "valid":
                        mode = Mode.Valid;
                        break;

                    case "invalid":
                        mode = Mode.Invalid;
                        break;

                    case "not-wf":
                        mode = Mode.NotWf;
                        break;

                    case "error":
                        mode = Mode.Error;
                        break;

                    default:
                        continue;
                    }

                    test.tests.Add(mode, new List <Entry>());
                }
                else if (mode != Mode.None && child is IHtmlTableElement)
                {
                    var list = test.tests[mode];
                    Inspect((IHtmlTableElement)child, list);
                }
            }

            return(test);
        }
예제 #3
0
        /// <summary>
        /// Generates the unit tests from the given overview document.
        /// </summary>
        /// <param name="document">The document to inspect.</param>
        public static XMLConfTest GenerateFromHtml(IDocument document)
        {
            var body = document.Body;
            var mode = Mode.None;
            var test = new XMLConfTest();

            for (int i = 0; i < body.ChildNodes.Length; i++)
            {
                var child = body.ChildNodes[i];
                var element = child as IHtmlAnchorElement;

                if (element != null && element.HasAttribute("name"))
                {
                    switch (element.GetAttribute("name"))
                    {
                        case "valid":
                            mode = Mode.Valid;
                            break;
                        case "invalid":
                            mode = Mode.Invalid;
                            break;
                        case "not-wf":
                            mode = Mode.NotWf;
                            break;
                        case "error":
                            mode = Mode.Error;
                            break;
                        default:
                            continue;
                    }

                    test.tests.Add(mode, new List<Entry>());
                }
                else if (mode != Mode.None && child is IHtmlTableElement)
                {
                    var list = test.tests[mode];
                    Inspect((IHtmlTableElement)child, list);
                }
            }

            return test;
        }