public void BuildOldUrlDomainReport() { var redirectProcessingResult = new RedirectProcessingResult { ParsedRedirects = TestData.TestData.GetParsedRedirects( new[] { new Redirect { OldUrl = "http://www.test1.local/url1", NewUrl = "http://www.test3.local" }, new Redirect { OldUrl = "http://www.test1.local/url2", NewUrl = "http://www.test3.local" }, new Redirect { OldUrl = "http://www.test2.local/url3", NewUrl = "http://www.test3.local" } }) }; // create and build old url domain report var oldUrlDomainReport = new OldUrlDomainReport(); oldUrlDomainReport.Build(redirectProcessingResult); // verify old url domains records are build var records = oldUrlDomainReport .GetRecords() .OfType <OldUrlDomainRecord>() .ToList(); Assert.AreEqual(2, records.Count); Assert.AreEqual( "www.test1.local", records[0].OldUrlDomain); Assert.AreEqual( "www.test2.local", records[1].OldUrlDomain); }
public void BuildProcessedRedirectReport() { var oldUrlRaw = "http://www.test.local/old"; var newUrlRaw = "http://www.test.local/new"; var configuration = TestData.TestData.DefaultConfiguration; var parsedRedirect = TestData.TestData.GetParsedRedirects( configuration, new[] { new Redirect { OldUrl = oldUrlRaw, NewUrl = newUrlRaw } }) .FirstOrDefault(); var redirectProcessingResult = new RedirectProcessingResult { ProcessedRedirects = new[] { new ProcessedRedirect { ParsedRedirect = parsedRedirect, Results = new [] { new Result { Type = ResultTypes.ExcludedRedirect, Message = ResultTypes.ExcludedRedirect, Url = newUrlRaw }, new Result { Type = ResultTypes.DuplicateOfFirst, Message = ResultTypes.DuplicateOfFirst, Url = newUrlRaw }, new Result { Type = ResultTypes.DuplicateOfLast, Message = ResultTypes.DuplicateOfLast, Url = newUrlRaw } } } } }; // create and build processed redirect report var urlHelper = new UrlHelper( configuration, new UrlParser(), new UrlFormatter()); var processedRedirectValidator = new ProcessedRedirectValidator( configuration, urlHelper); var outputRedirectBuilder = new OutputRedirectBuilder (processedRedirectValidator); var processedRedirectReport = new ProcessedRedirectReport( outputRedirectBuilder); processedRedirectReport.Build(redirectProcessingResult); // verify processed redirect records are build var records = processedRedirectReport .GetRecords() .ToList(); Assert.AreEqual(1, records.Count); Assert.AreEqual( oldUrlRaw, records[0].OriginalOldUrl); Assert.AreEqual( newUrlRaw, records[0].OriginalNewUrl); Assert.AreEqual( oldUrlRaw, records[0].ParsedOldUrl); Assert.AreEqual( newUrlRaw, records[0].ParsedNewUrl); Assert.AreEqual( 3, records[0].ResultCount); Assert.AreEqual( string.Join(",", new [] { ResultTypes.DuplicateOfFirst, ResultTypes.DuplicateOfLast, ResultTypes.ExcludedRedirect }), records[0].ResultTypes); Assert.AreEqual( true, records[0].ExcludedRedirect); Assert.AreEqual( ResultTypes.ExcludedRedirect, records[0].ExcludedRedirectMessage); Assert.AreEqual( newUrlRaw, records[0].ExcludedRedirectUrl); Assert.AreEqual( true, records[0].DuplicateOfFirst); Assert.AreEqual( ResultTypes.DuplicateOfFirst, records[0].DuplicateOfFirstMessage); Assert.AreEqual( newUrlRaw, records[0].DuplicateOfFirstUrl); Assert.AreEqual( true, records[0].DuplicateOfLast); Assert.AreEqual( ResultTypes.DuplicateOfLast, records[0].DuplicateOfLastMessage); Assert.AreEqual( newUrlRaw, records[0].DuplicateOfLastUrl); }
public void BuildRedirectSummaryReport() { var oldUrlRaw = "http://www.test.local/old"; var newUrlRaw = "http://www.test.local/new"; var oldUrlParsed = new Uri(oldUrlRaw); var newUrlParsed = new Uri(newUrlRaw); var parsedRedirect = TestData.TestData.GetParsedRedirects( new[] { new Redirect { OldUrl = "http://www.test.local/old", NewUrl = "http://www.test.local/new" } }) .FirstOrDefault(); var redirectProcessingResult = new RedirectProcessingResult { ProcessedRedirects = new[] { new ProcessedRedirect { ParsedRedirect = parsedRedirect, Results = new [] { new Result { Type = ResultTypes.ExcludedRedirect, Message = ResultTypes.ExcludedRedirect, Url = newUrlRaw }, new Result { Type = ResultTypes.DuplicateOfFirst, Message = ResultTypes.DuplicateOfFirst, Url = newUrlRaw }, new Result { Type = ResultTypes.DuplicateOfLast, Message = ResultTypes.DuplicateOfLast, Url = newUrlRaw } } } } }; // create and build redirect summary report var configuration = TestData.TestData.DefaultConfiguration; var urlFormatter = new UrlFormatter(); var urlParser = new UrlParser(); var urlHelper = new UrlHelper( configuration, urlParser, urlFormatter); var redirectSummaryReport = new RedirectSummaryReport( new ProcessedRedirectValidator( configuration, urlHelper)); redirectSummaryReport.Build(redirectProcessingResult); // verify redirect summary records are build var records = redirectSummaryReport .GetRecords() .ToList(); Assert.AreNotEqual(0, records.Count); }