コード例 #1
0
        public void WhenNoRouteInRouteTable_GetFalseAndNullRoute()
        {
            // Arrange
            var routeTable = new RouteTable();

            // Act
            RequestRoute route;
            var          result = routeTable.HasRouteToPath("Name", out route);

            // Assert
            Assert.IsFalse(result);
            Assert.IsNull(route);
        }
コード例 #2
0
        public void WhenRouteInRouteTable_GetTrueAndSetRouteInRequest()
        {
            // Arrange
            var routeTable         = new RouteTable();
            var mockControllerType = typeof(MockController);
            var methods            = new ArrayList();

            methods.Add("Index");
            routeTable.Routes.Add(new Route(mockControllerType, "Mock", mockControllerType.Name, mockControllerType.FullName, methods));

            // Act
            RequestRoute route;
            var          result = routeTable.HasRouteToPath("/Mock/Index", out route);

            // Assert
            Assert.IsTrue(result);
            Assert.AreEqual(mockControllerType, route.Route.ControllerType);
        }
コード例 #3
0
        public void WhenPathWithNoIdentifierAndNoDefaultController_GetFalseAndNullRoute()
        {
            // Arrange
            var routeTable         = new RouteTable();
            var mockControllerType = typeof(MockController);
            var methods            = new ArrayList();

            methods.Add("Index");
            routeTable.Routes.Add(new Route(mockControllerType, "Mock", mockControllerType.Name, mockControllerType.FullName, methods));

            // Act
            RequestRoute route;
            var          result = routeTable.HasRouteToPath("//", out route);

            // Assert
            Assert.IsFalse(result);
            Assert.IsNull(route);
        }
コード例 #4
0
        public void WhenRouteInRouteTableAndNoExistingMethod_GetFalseAndNoRoute()
        {
            // Arrange
            var routeTable         = new RouteTable();
            var mockControllerType = typeof(MockController);
            var methods            = new ArrayList();

            methods.Add("Index");
            routeTable.Routes.Add(new Route(mockControllerType, "Mock", mockControllerType.Name, mockControllerType.FullName, methods));

            // Act
            RequestRoute route;
            var          result = routeTable.HasRouteToPath("/Mock/MyNotExistingMethod", out route);

            // Assert
            Assert.IsFalse(result);
            Assert.IsNull(route);
        }
コード例 #5
0
        public void WhenNoPathAndDefaultController_GetRouteToDefaultController()
        {
            // Arrange
            var defaultControllerName = "Mock";
            var routeTable            = new RouteTable();
            var mockControllerType    = typeof(MockController);
            var methods = new ArrayList();

            methods.Add("Index");
            routeTable.Routes.Add(new Route(mockControllerType, "Mock", mockControllerType.Name, mockControllerType.FullName, methods));
            routeTable.DefaultControllerName = defaultControllerName;

            // Act
            RequestRoute route;
            var          result = routeTable.HasRouteToPath("/", out route);

            // Assert
            Assert.IsTrue(result);
            Assert.AreEqual(defaultControllerName, route.Route.ControllerName);
        }