public void Return_False_With_Valid_Taxon_With_Page()
        {
            ITaxon taxon;
            int pageIndex;

            string validUrlPattern = "-in-tags/tag/tag1";

            string requestedUrl = "-in-tags/tag/tag1/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);
            Assert.IsTrue(pageIndex == 0);
        }
        public void Taxonomy_UrlParams_Mapper_Test_With_PageIndex()
        {
            string urlPattern = "-in-tags/tag/tag1/3";

            var urlParams = urlPattern.Split('/');

            var controller = new TestableController();
            controller.ControllerContext = new ControllerContext();

            var tagTaxon = new FlatTaxon();

            var taxonomyUrlParamsMapper = new TaxonomyUrlParamsMapper(
                                          controller,
                                          new TaxonUrlMapper(new MockedTaxonUrlEvaluatorAdapter(url => url.Contains(urlPattern) ? tagTaxon : null)));

            taxonomyUrlParamsMapper.ResolveUrlParams(urlParams, controller.ControllerContext.RequestContext);

            Assert.IsTrue(controller.ControllerContext.RequestContext.RouteData.Values["action"] == "ListByTaxon");
            Assert.IsTrue(controller.ControllerContext.RequestContext.RouteData.Values["taxon"] == tagTaxon);
            Assert.IsTrue(((int)controller.ControllerContext.RequestContext.RouteData.Values["page"]) == 3);
        }
        public void Taxonomy_UrlParams_Mapper_Test_With_PageIndex_With_Incorrect_Route_Data()
        {
            string urlPattern = "-in-tags/tag/tag1/3";

            string requestRouteData = "-in-tags/tag/tag1/asdasd";

            var urlParams = requestRouteData.Split('/');

            var controller = new TestableController();
            controller.ControllerContext = new ControllerContext();

            var tagTaxon = new FlatTaxon();

            var taxonomyUrlParamsMapper = new TaxonomyUrlParamsMapper(
                                          controller,
                                          new TaxonUrlMapper(new MockedTaxonUrlEvaluatorAdapter(url => url.Contains(urlPattern) ? tagTaxon : null)));

            taxonomyUrlParamsMapper.ResolveUrlParams(urlParams, controller.ControllerContext.RequestContext);

            Assert.IsFalse(controller.ControllerContext.RequestContext.RouteData.Values["action"] == "ListByTaxon");
        }
        public void Return_True_With_Valid_Taxon_And_PageIndex_Equals_To_3()
        {
            ITaxon taxon;
            int pageIndex;

            string urlWithTaxon = "-in-tags/tag/tag1";

            string urlPattern = "-in-tags/tag/tag1/3";

            var urlParams = urlPattern.Split('/');

            var tagTaxon = new FlatTaxon();

            var taxonUrlMapper = new TaxonUrlMapper(new MockedTaxonUrlEvaluatorAdapter(url => url.Contains(urlWithTaxon) ? tagTaxon : null));

            bool hasMatch = taxonUrlMapper.TryMatch(urlParams, out taxon, out pageIndex);

            Assert.IsTrue(hasMatch);
            Assert.IsTrue(pageIndex == 3);
        }