public HyperLinkParserTestCase Merge(HyperLinkParserTestCase arg)
        {
            var newContent = this.ContentToParse + arg.ContentToParse;
            var newLinks   = new List <HyperLink>();

            newLinks.AddRange(this.ExpectedLinks);
            newLinks.AddRange(arg.ExpectedLinks);

            return(new HyperLinkParserTestCase(newContent, newLinks));
        }
        public static List <HyperLinkParserTestCase> GenerateGoodTestCases()
        {
            // Initialization
            TestCasePart[] attributeInformation =
                GenerateAttributes();
            string[] leftOfAttr  = GoodLeftOfHrefText();
            string[] rightOfAttr = GoodRightOfHrefText();
            string[] text        = TEXT;

            int numTestCases = attributeInformation.Length * leftOfAttr.Length * rightOfAttr.Length * text.Length;

            Console.WriteLine("Number of test cases = {0}", numTestCases);
            var testCases = new List <HyperLinkParserTestCase>(numTestCases);

            foreach (var part in attributeInformation)
            {
                foreach (var left in leftOfAttr)
                {
                    foreach (var right in rightOfAttr)
                    {
                        foreach (var inner in text)
                        {
                            string content = string.Format(A_TEMPLATES[0], left + part.Attr + right, inner);
                            HyperLinkParserTestCase testCase = null;
                            if (part.IsCorrectScheme)
                            {
                                testCase = new HyperLinkParserTestCase(content, Create(part.Path, inner, content));
                            }
                            else
                            {
                                testCase = new HyperLinkParserTestCase(content);
                            }

                            testCases.Add(testCase);
                        }
                    }
                }
            }

            return(testCases);
        }
        public void TestParse()
        {
            var tests    = HyperLinkParserTestCase.GenerateGoodTestCases();
            var badTests = HyperLinkParserTestCase.GenerateBadTestCases();

            tests.AddRange(badTests);
            int ctr = 0;

            for (int i = 0; i < tests.Count; i++)
            {
                var item = tests[i];
                item.PerformTest();

                if (item.ExpectedLinks.Count == 1 && item.ExpectedLinks[0].AbsoluteUri != null && ctr < 3)
                {
                    foreach (var badItem in badTests)
                    {
                        tests.Add(badItem.Merge(item));
                        tests.Add(item.Merge(badItem));
                    }
                    ctr++;
                }
            }
        }
        public HyperLinkParserTestCase Merge(HyperLinkParserTestCase arg)
        {
            var newContent = this.ContentToParse + arg.ContentToParse;
            var newLinks = new List<HyperLink>();
            newLinks.AddRange(this.ExpectedLinks);
            newLinks.AddRange(arg.ExpectedLinks);

            return new HyperLinkParserTestCase(newContent, newLinks);
        }
        public static List<HyperLinkParserTestCase> GenerateGoodTestCases()
        {
            // Initialization
            TestCasePart[] attributeInformation = 
                GenerateAttributes();
            string[] leftOfAttr = GoodLeftOfHrefText();
            string[] rightOfAttr = GoodRightOfHrefText();
            string[] text = TEXT;

            int numTestCases = attributeInformation.Length * leftOfAttr.Length * rightOfAttr.Length * text.Length;
            Console.WriteLine("Number of test cases = {0}", numTestCases);
            var testCases = new List<HyperLinkParserTestCase>(numTestCases);
            foreach(var part in attributeInformation) {
                foreach(var left in leftOfAttr) {
                    foreach(var right in rightOfAttr) {
                        foreach(var inner in text) {
                            string content = string.Format(A_TEMPLATES[0], left + part.Attr + right, inner);
                            HyperLinkParserTestCase testCase = null;
                            if (part.IsCorrectScheme)
                            {
                                testCase = new HyperLinkParserTestCase(content, Create(part.Path, inner, content));
                            }
                            else
                            {
                                testCase = new HyperLinkParserTestCase(content);
                            }
                             
                            testCases.Add(testCase);
                        }
                    }
                }
            }

            return testCases;
        }