Exemplo n.º 1
0
        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");
        }
Exemplo n.º 2
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);
        }