예제 #1
0
        public void BuildNewUrlDomainReport()
        {
            var redirectProcessingResult = new RedirectProcessingResult
            {
                ParsedRedirects = TestData.TestData.GetParsedRedirects(
                    new[]
                {
                    new Redirect
                    {
                        OldUrl = "http://www.test1.local/url1",
                        NewUrl = "http://www.test3.local/url8"
                    },
                    new Redirect
                    {
                        OldUrl = "http://www.test1.local/url2",
                        NewUrl = "http://www.test2.local/url5"
                    },
                    new Redirect
                    {
                        OldUrl = "http://www.test2.local/url3",
                        NewUrl = "http://www.test2.local/url9"
                    }
                })
            };

            // create and build new url domain report
            var newUrlDomainReport = new NewUrlDomainReport();

            newUrlDomainReport.Build(redirectProcessingResult);

            // verify new url domains records are build
            var records = newUrlDomainReport
                          .GetRecords()
                          .ToList();

            Assert.AreEqual(2, records.Count);
            Assert.AreEqual(
                "www.test2.local",
                records[0].NewUrlDomain);
            Assert.AreEqual(
                "www.test3.local",
                records[1].NewUrlDomain);
        }
        static void Reports(
            string outputDir,
            IRedirectProcessingResult redirectProcessingResult,
            IProcessedRedirectValidator processedRedirectValidator)
        {
            // create and write redirect summary report
            // ----------------------------------------
            var redirectSummaryReportCsvFile = Path.Combine(
                outputDir,
                "redirect_summary.csv");

            System.Console.ForegroundColor = ConsoleColor.Yellow;
            System.Console.WriteLine(
                string.Format(
                    "Building and writing redirect summary report file '{0}'",
                    redirectSummaryReportCsvFile));

            var redirectSummaryReport =
                new RedirectSummaryReport(
                    processedRedirectValidator);

            redirectSummaryReport.Build(
                redirectProcessingResult);
            redirectSummaryReport.WriteReportCsvFile(
                redirectSummaryReportCsvFile);

            System.Console.ForegroundColor = ConsoleColor.Green;
            System.Console.WriteLine("Done");
            System.Console.WriteLine(string.Empty);

            // create and write old url domain report
            // --------------------------------------
            var oldUrlDomainReportCsvFile = Path.Combine(
                outputDir,
                "oldurl_domains.csv");

            System.Console.ForegroundColor = ConsoleColor.Yellow;
            System.Console.WriteLine(
                string.Format(
                    "Building and writing old url domains report file '{0}'",
                    oldUrlDomainReportCsvFile));

            var oldUrlDomainReport =
                new OldUrlDomainReport();

            oldUrlDomainReport.Build(
                redirectProcessingResult);
            oldUrlDomainReport.WriteReportCsvFile(
                oldUrlDomainReportCsvFile);

            System.Console.ForegroundColor = ConsoleColor.Green;
            System.Console.WriteLine("Done");
            System.Console.WriteLine(string.Empty);

            // create and write new url domain report
            // --------------------------------------
            var newUrlDomainReportCsvFile = Path.Combine(
                outputDir,
                "newurl_domains.csv");

            System.Console.ForegroundColor = ConsoleColor.Yellow;
            System.Console.WriteLine(
                string.Format(
                    "Building and writing new url domains report file '{0}'",
                    newUrlDomainReportCsvFile));

            var newUrlDomainReport =
                new NewUrlDomainReport();

            newUrlDomainReport.Build(
                redirectProcessingResult);
            newUrlDomainReport.WriteReportCsvFile(
                newUrlDomainReportCsvFile);

            System.Console.ForegroundColor = ConsoleColor.Green;
            System.Console.WriteLine("Done");
            System.Console.WriteLine(string.Empty);

            // create and write processed redirect report
            // ------------------------------------------
            var processedRedirectReportCsvFile = Path.Combine(
                outputDir,
                "processed_redirects.csv");

            System.Console.ForegroundColor = ConsoleColor.Yellow;
            System.Console.WriteLine(
                string.Format(
                    "Building and writing processed redirects report file '{0}'",
                    processedRedirectReportCsvFile));

            var outputRedirectBuilder = new OutputRedirectBuilder(
                processedRedirectValidator);
            var processedRedirectReport =
                new ProcessedRedirectReport(
                    outputRedirectBuilder);

            processedRedirectReport.Build(
                redirectProcessingResult);
            processedRedirectReport.WriteReportCsvFile(
                processedRedirectReportCsvFile);

            System.Console.ForegroundColor = ConsoleColor.Green;
            System.Console.WriteLine("Done");
            System.Console.WriteLine(string.Empty);

            // create and write output redirect report
            // ---------------------------------------
            var outputRedirectReportCsvFile = Path.Combine(
                outputDir,
                "output_redirects.csv");

            System.Console.ForegroundColor = ConsoleColor.Yellow;
            System.Console.WriteLine(
                string.Format(
                    "Building and writing output redirects report file '{0}'",
                    outputRedirectReportCsvFile));

            var outputRedirectReport =
                new OutputRedirectReport(
                    outputRedirectBuilder,
                    false);

            outputRedirectReport.Build(
                redirectProcessingResult);
            outputRedirectReport.WriteReportCsvFile(
                outputRedirectReportCsvFile);

            System.Console.ForegroundColor = ConsoleColor.Green;
            System.Console.WriteLine("Done");
            System.Console.WriteLine(string.Empty);

            // create and write output redirect including not matching new url report
            // ----------------------------------------------------------------------
            var outputRedirectIncludingNotMatchingNewUrlReportCsvFile = Path.Combine(
                outputDir,
                "output_redirects_incl_not_matching.csv");

            System.Console.ForegroundColor = ConsoleColor.Yellow;
            System.Console.WriteLine(
                string.Format(
                    "Building and writing output redirects including not matching new url report file '{0}'",
                    outputRedirectIncludingNotMatchingNewUrlReportCsvFile));

            var outputRedirectIncludingNotMatchingNewUrlReport =
                new OutputRedirectReport(
                    outputRedirectBuilder,
                    true);

            outputRedirectIncludingNotMatchingNewUrlReport.Build(
                redirectProcessingResult);
            outputRedirectIncludingNotMatchingNewUrlReport.WriteReportCsvFile(
                outputRedirectIncludingNotMatchingNewUrlReportCsvFile);

            System.Console.ForegroundColor = ConsoleColor.Green;
            System.Console.WriteLine("Done");
            System.Console.ForegroundColor = ConsoleColor.Gray;
        }