Esempio n. 1
0
        public void SectoionControllerRedirectedToCorrectPage()
        {
            var requestDispatcherFactoryMock = new Mock <IRequestDispatcherFactory>();
            var routeNavigationServiceMock   = new Mock <IRouteNavigationService>();

            routeNavigationServiceMock.Setup(i => i.GetInitialRoute(It.IsAny <long?> ()))
            .Returns(new RouteInfo("GeneralInformationSection", 0));
            var patientAccessControlManagerMock = new Mock <IPatientAccessControlManager>();

            var assessmentController = new AssessmentController(requestDispatcherFactoryMock.Object,
                                                                routeNavigationServiceMock.Object,
                                                                patientAccessControlManagerMock.Object);

            var result = assessmentController.Edit(It.IsAny <long>());

            Assert.IsNotNull(result);
            var redirectToRouteResult = result as RedirectToRouteResult;

            Assert.AreEqual(redirectToRouteResult.RouteName, "SectionRoute");

            var routes = new RouteCollection();

            RouteConfig.RegisterRoutes(routes);
            RouteTestHelper.AssertRoute(routes, redirectToRouteResult.RouteValues, new { id = "0", section = "GeneralInformationSection" });
        }
Esempio n. 2
0
 public void MatchRoutes()
 {
     RouteTestHelper.TestRouteMatch("~/Error/HttpError", "Error", "HttpError");
     RouteTestHelper.TestRouteMatch("~/Error/Http404", "Error", "Http404");
     RouteTestHelper.TestRouteMatch("~/interview/GenernalInformationSection/Edit/1", "Section", "Edit");
     RouteTestHelper.TestRouteMatch("~/interview/DrugAndAlcoholSection/AlcoholUse/Edit/1", "Section", "Edit");
 }
Esempio n. 3
0
        public void RouteHasDefaultActionWhenUrlWithoutAction()
        {
            var routes = new RouteCollection();

            RouteConfig.RegisterRoutes(routes);

            RouteTestHelper.AssertRoute(routes, "~/patient", new { controller = "patient", action = "index" });
        }
Esempio n. 4
0
        public void CanMapNormalControllerActionRoute()
        {
            var routes = new RouteCollection();

            RouteConfig.RegisterRoutes(routes);

            var httpContextMock = new Mock <HttpContextBase>();

            httpContextMock.Setup(c => c.Request.AppRelativeCurrentExecutionFilePath).Returns("~/patient/index");

            var routeData = routes.GetRouteData(httpContextMock.Object);

            Assert.IsNotNull(routeData);
            RouteTestHelper.AssertRoute(routes, routeData.Values, new { controller = "patient", action = "index" });
        }
Esempio n. 5
0
        public void TestOutgoingRoutes()
        {
            var routes = new RouteCollection();

            RouteConfig.RegisterRoutes(routes);

            var context = new RequestContext(RouteTestHelper.CreateHttpContext(), new RouteData());

            var result      = UrlHelper.GenerateUrl(null, "Index", "Home", null, routes, context, true);
            var routeValues = new RouteValueDictionary();

            routeValues.Add("Id", "TheId");
            string result2 = UrlHelper.GenerateUrl(null, "Index", "Home", routeValues, routes, context, true);

            Assert.AreEqual("/", result);
            Assert.AreEqual("/Home/Index/TheId", result2);
        }