public void Return_False_When_Params_Are_Empty_Test() { var taxonUrlMapper = new TaxonUrlMapper(new MockedTaxonUrlEvaluatorAdapter()); ITaxon taxon; int pageIndex; bool hasMatch = taxonUrlMapper.TryMatch(new string[1], out taxon, out pageIndex); Assert.IsFalse(hasMatch); }
public void Return_False_When_Params_Has_Less_Then_Tree_Items() { var taxonUrlMapper = new TaxonUrlMapper(new MockedTaxonUrlEvaluatorAdapter()); ITaxon taxon; int pageIndex; var urlParams = new[] { "-in-tags", "tag" }; bool hasMatch = taxonUrlMapper.TryMatch(urlParams, out taxon, out pageIndex); Assert.IsFalse(hasMatch); }
public void Return_True_With_Valid_HierarchicalTaxon_With_Deep_Hierarchy() { ITaxon taxon; int pageIndex; string requestedUrl = "-in-category/category/cat1/cat11/cat22/cat33/cat44"; var urlParams = requestedUrl.Split('/'); var tagTaxon = new HierarchicalTaxon(); var taxonUrlMapper = new TaxonUrlMapper(new MockedTaxonUrlEvaluatorAdapter(url => url.Contains(requestedUrl) ? tagTaxon : null)); bool hasMatch = taxonUrlMapper.TryMatch(urlParams, out taxon, out pageIndex); Assert.IsTrue(hasMatch); }
public void Return_True_With_Valid_Taxon() { ITaxon taxon; int pageIndex; string urlPattern = "-in-tags/tag/tag1"; var urlParams = urlPattern.Split('/'); var tagTaxon = new FlatTaxon(); var taxonUrlMapper = new TaxonUrlMapper(new MockedTaxonUrlEvaluatorAdapter(url => url.Contains(urlPattern) ? tagTaxon : null)); bool hasMatch = taxonUrlMapper.TryMatch(urlParams, out taxon, out pageIndex); Assert.IsTrue(hasMatch); Assert.IsTrue(pageIndex == 0); }
public void Return_False_With_Valid_Taxon_With_PageUrl_PageIndex_PageUrl() { ITaxon taxon; int pageIndex; string validUrlPattern = "-in-tags/tag/tag1"; string requestedUrl = "-in-tags/tag/tag1/page/1/page"; var urlParams = requestedUrl.Split('/'); var tagTaxon = new FlatTaxon(); var taxonUrlMapper = new TaxonUrlMapper(new MockedTaxonUrlEvaluatorAdapter(url => url.Contains(validUrlPattern) ? tagTaxon : null)); bool hasMatch = taxonUrlMapper.TryMatch(urlParams, out taxon, out pageIndex); Assert.IsFalse(hasMatch); }